0

This works fine but I want to “limit” the number of times the snippet shows up at the top of each entry, I only want it to show up on the top (one time in category “7”, no mater haw many entries.

Any suggestions?

{exp:channel:categories channel="event_calendar" style="linear" }
<h2><a href="{path='events/show/'}" />{category_name}</a></h2>
{/exp:channel:categories} 

{exp:channel:entries channel="event_calendar" dynamic="no"}

{if category_id == "7"} {snippet-rodeo-intro}{/if}

<h2 class="event-header">{event_name}</h2> 
{event_description}

{/exp:channel:entries}
1

An alternative answer, doesn't use any additional plugins or anything.

I am assuming you want a category jump list a the top (hence the categories tag pair), then the entries in a decending fashion, grouped by category, with a snippet at the top of each category right?

Assuming this, what I've done is make a category loop, then use an inner entries loop to display the entries just for the outer category. Finally we use the {absolute_count} tag to target just the first entry.

{exp:channel:categories channel="event_calendar" style="linear" }
  <h2><a href="{path='events/show/'}" />{category_name}</a></h2>
{/exp:channel:categories} 

{exp:channel:categories channel="event_calendar" style="linear"}
  {exp:channel:entries channel="event_calendar" dynamic="no" category="{category_id}"}
    {if category_id == "7" && absolute_count == 1} 
      {snippet-rodeo-intro}
    {/if}

    <h2 class="event-header">{event_name}</h2> 
    {event_description}
  {/exp:channel:entries}
| improve this answer | |
0

Not sure exactly what you are trying to do, but I think you might get away with just adding cat_limit="1" to your channel:entries tag. More on this here.

If that doesn't do what you want, the other option is to simply post a flag to a variable when you display the snippet and a test for it being set. There are various EE extensions that allow you to write to variables during execution - this uses CE_Variables, but there are many others.

{if category_id == "7" AND {exp:ce_vars:snippet_flag} != "1"}
 {snippet-rodeo-intro}
 {exp:ce_vars:set snippet_flag="1"}
{/if}

HTH

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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