Hey,
I’ve been researching the web for a few hours and trying multiple things with no luck.
One of my custom fields is a cover image and I’m trying to define how the output is going to look based on the category of the entry.
Here’s my code:
{!-- If entry has Cover --}
{if entry_cover}
<div class="cover">
{categories}
{if category_id == '2'}
{entry_cover}
<a href="http://{page_url}">{path}_xlo/{filename}.{extension}</a>
{/entry_cover}
{if:else}
{entry_cover}
<a href="http://{page_url}">{path}_xl/{filename}.{extension}</a>
{/entry_cover}
{/if}
{/categories}
</div>
{/if}The problem is that the “else” statement isn’t working. When there’s no image it will simply ignore everything. Is there a problem with including a field multiple times? If so is there a workaround?
I also tried the following syntax with no luck:
{!-- If entry has Cover --}
{if entry_cover}
<div class="cover">
{entry_cover}
<a href="http://{page_url}">_ <a href="_ {path}_ {categories}_ {if category_id == 8GvF9n3wHCcx2Docrpb3kACYrsYvLeeatypography_img_src_end2} _xlo/ {if:else} _xl/ {/if}_ {filename}.{extension} tag={url_title} ">_ {path}_ {categories}_ {if category_id == 8GvF9n3wHCcx2Docrpb3kACYrsYvLeeatypography_img_src_end2} _xlo/ {if:else} _xl/ {/if}_ {filename}.{extension} tag={url_title} </a>_ </a>
{/entry_cover}
</div>
{/if}This results in {entry_cover}{/entry_cover} being showed as text with an <img> tag with no source.
Any suggestions?
EDIT: It looks like some of the characters in my second code sample were being escaped. Had to add some spaces and line breaks to avoid this. There are no spaces or line breaks in the <img> tag.