In channel entries tag I have something like this
{if category =="39|50|51"} do this {if:else} do that {/if}if statement is not working. I do not get it why. there are no variables for channel entries so I presume that is part of the problem. But how to do it then? How to check if entry has category to display one message, if it has another display something else
{exp:channel:entries channel="katalog" limit="12" dynamic="yes" status="open" show_future_entries="no" orderby="date" sort="desc" disable="member_data" pagination="bottom"}
{if category =="39|50|51"}
{exp:channel_images:images entry_id="{entry_id}" channel="katalog" limit="1" cover_only="yes"}
show image
{if image:no_images}
show alternative image that says NO IMAGE found
{/if}
{/exp:channel_images:images}
{if:else}
show something completely else for entries that are not in category 39, 50 or 51
{/if}
{/exp:channel:entries}Did you get this resolved? In order to call categories to use in a conditional, you need to use the categories looping pair. https://ellislab.com/expressionengine/user-guide/add-ons/channel/channel_entries.html#categories. Then you need to use the {category_id} in your conditional.
You can guess though that doing things this way might be tricky with the conditional logic you’re currently using. Since a post can have multiple categories the contents of the conditional would be output once per match with a category…
I’m not sure categories is the best way to approach the functionality you’re trying to provide. You’d be calling three nested loops (the entries, then the categories, then the dev-demon channel images), which it seems to me isn’t very efficient to grab one image.
Why not create another custom field for “post_featured_image” and use a conditional like {if post_featured_image} instead? I know that’s not the answer you were looking for, but it would certainly be more efficient!
Are other categories going to have channel-images associated with them?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.