carasmo wrote:Then you put the one with the -> value in the image tagCode: Select all
{if $entry->fieldsbyname.mainimage != ''} {*if the field is not empty*} {$entry->fieldsbyname.mainimage->value} {/if}
if the field is Main Image (not mainimage) note the caps and the space, then that's a different matter.
if the field is Mainimage thenCode: Select all
{assign var='mainimage' value='Main Image'} {if $entry->fieldsbyname.$mainimage != ''} {$entry->fieldsbyname.$mainimage->value}{/if}
Notice it's case sensitive mainimage is not Mainimage and Main Image is not main_image. You would use the appropriate syntax for the job.Code: Select all
{if $entry->fieldsbyname.Mainimage != ''} {$entry->fieldsbyname.Mainimage->value}{/if}
Field Definitions in News and Blog
Field Definitions in News and Blog
Re: Field Definitions in News and Blog
Are you sure you are checking for if a value exists or if just the field name exists.
Should it not be e.g.
Though depends on the field type and default value.
Should it not be e.g.
Code: Select all
{if $entry->fieldsbyname.Mainimage->value}
do something
{/if}
Re: Field Definitions in News and Blog
If there's nothing in the field, it'd print the container like an empty p tag, so if the value exists then do it. If the image exists, then load the figure tag, etc.,
Haven't tried what you wrote, got the if not empty from elsewhere...
Haven't tried what you wrote, got the if not empty from elsewhere...
Re: Field Definitions in News and Blog
Ok just trying suggest a potential shorthand version. Try it.
Re: Field Definitions in News and Blog
Thanks! I will.