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 Answers 2

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}

0
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".

1
  • 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. Commented Nov 4, 2012 at 21:13

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.