I'd like to hide a menu item called 'Events and Activties', if there are no entries in that particular channel. I've tried to do this using this code but it's not working:

<ul class="nav-bar">
                    <li class="{if segment_1 !=""}not-{/if}current"><a href="{path=/}" class="main"><span>Home</span></a></li>
                    <li class="{if segment_1 !="case-studies"}not-{/if}current"><a href="{path=case-studies}" class="main">People <span>in {lv_siteSector}</span></a></li>
                    <li class="{if segment_1 !="job-profiles"}not-{/if}current"><a href="{path=job-profiles}" class="main">Careers <span>in {lv_siteSector}</span></a></li>
                    <li class="{if segment_1 !="ask-an-expert"}not-{/if}current"><a href="{path=ask-an-expert}" class="main">Ask <span>an expert</span></a></li>
                    <li class="{if segment_1 !="jobs-opportunities"}not-{/if}current"><a href="{path=jobs-opportunities}" class="main">Jobs &amp; <span>opportunities</span></a></li>
                    {exp:channel:entries channel="choices_events" site="default_site" show_future_entries="yes" show_expired="no" status="open"}
                        {if count == 1}
                        <li class="{if segment_1 !="getting-started"}not-{/if}current"><a href="{path=getting-started}" class="main">Events &amp; <span>activities</span></a></li>

Any help would be very much appreciated.



1 Answer 1


Expression Engine will be trying to determine the parameters for your channel entries tag dynamically from the url so you need to turn this off. You can do that with the dynamic="no" parameter. You probably should just get one entry to save on overhead using limit="1". This will also simplify your code as you won't need to use the count conditional. Adding the disable parameter will further optimise things by turning off the data you don't need such as categories, member data and custom fields. Try using this code:

{exp:channel:entries channel="choices_events" site="default_site" dynamic="no" limit="1" show_future_entries="yes" show_expired="no" status="open" disable="custom_fields|categories|member_data"}
  <li class="{if segment_1 !="getting-started"}not-{/if}current"><a href="{path=getting-started}" class="main">Events &amp; <span>activities</span></a></li>                      

You may need to exclude custom_fields from the disable parameter if you need to use any fields you've defined for the channel.

  • Yes that work's perfect. Thank you very much. Apr 4, 2013 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.