How to apply images conditionally using records and categories?

Using ExpressionEngine version 2.5.3, I have a list of products displayed by category, but I need high-quality products from this list that are presented with a small star image. What do you conditionally call these little stars other than {title}?

This code currently shows stars for all products, and this 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.

+7
source share
2 answers

It is best to set a new check box named "is_premium" with the value set to "y".

Then edit each entry of the premium product and check the box and save.

Finally, use your conditional expression in your template. {if is_premium == "y"} add starcode {/ if}

+6
source

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

An alternative approach is to process it with a user status, and not with a custom field, if only you can quickly and easily see and sort the list on the main editing screen by β€œpremium” (Zenbu can add a custom field to the editing screen, of course) . The condition will be similar, and, of course, the record loop should have the status parameter "open | premium".

+1
source

All Articles