7

Using version 2.5.3 of ExpressionEngine, I have a list of products displayed by category, but I need the premium products among this list being featured with a small star image. How do you call conditionally this little stars besides the {title}?

At the moment this code shows stars for all products and that is not ideal.

<ol class="voices-list">
{exp:channel:entries channel="product" orderby="title" sort="asc" category="2&6" dynamic="no"}  
<li><a href="{page_url}">{title}<img class="feature_icon medium" src="{root_url}img/audio/smallstar.png" alt="star"></a></li>   
{/exp:channel:entries}
</ol>

I need your help, please.

2 Answers2

6

Best to set up a new checkbox field named "is_premium" with the value set to "y".

Next, edit each premium product entry and check the box and save.

Finally, in your template use this conditional. {if is_premium == "y"}add star code{/if}

Anna_MediaGirl
  • 1,120
  • 13
  • 31
1

I like the approach shown in the answer posted by @MediaGirl and have used it many times.

An alternative approach is to handle it with a custom status rather than a custom field, if only to have the ability on the main edit screen to quickly and easily see and sort the list by "premium" (Zenbu could add the custom field to the edit screen, of course). The conditional would be similar, and of course the entries loop would need to have the status param of "open|premium".

Alex Kendrick
  • 969
  • 9
  • 18
Jean St-Amand
  • 793
  • 5
  • 12
  • It's a terrific add-on for customizing the edit screen to include custom fields that help the editor find what they're looking for. Worth a look for sure. – Jean St-Amand Nov 04 '12 at 21:13