Page 1 of 1

[solved] News: Field Definitions not working v 1.11

Posted: Tue Jul 31, 2012 1:24 pm
by hanover
Hello
I have a field definitions called "mainimage" (public). I put the full url of an image in that field, but it is not displaying during the news summary output. I had this working in the version1.10.3 is it a bug or am I doing something wrong in the code?



{foreach from=$items item=entry}

{if isset($entry->mainimage)}
<img src="{eval var=$entry->mainimage}"/>
{/if}

<strong><a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{$entry->title|cms_escape}</a></strong>
{/foreach}

Re: News: Field Definitions not working v 1.11

Posted: Tue Jul 31, 2012 1:50 pm
by calguy1000
Custom Field values are no longer 'munged' and copied into the main 'entry' object.

You must access them via the $entry->fields array.

Re: News: Field Definitions not working v 1.11

Posted: Tue Jul 31, 2012 1:59 pm
by hanover
Hi Calguy
Thank you for the reply. I am not an expert, is it possible for you to show an example?

Re: News: Field Definitions not working v 1.11

Posted: Wed Aug 01, 2012 6:03 am
by hanover
From the sample summary template I used the "extra" field as a template


{if isset($entry->extra)}
<div class="NewsSummaryExtra">
{eval var=$entry->extra}

</div>
{/if}

but my custom field name is "mainimage"

Re: News: Field Definitions not working v 1.11

Posted: Wed Aug 01, 2012 9:45 pm
by carasmo

Code: Select all

{if $entry->fieldsbyname.mainimage != ''} {*if the field is not empty*}

{$entry->fieldsbyname.mainimage->value}

{/if}
Then you put the one with the -> value in the image tag

if the field is Main Image (not mainimage) note the caps and the space, then that's a different matter.

Code: Select all

{assign var='mainimage' value='Main Image'}
{if $entry->fieldsbyname.$mainimage != ''}
{$entry->fieldsbyname.$mainimage->value}{/if}
if the field is Mainimage then

Code: Select all

{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.

Re: News: Field Definitions not working v 1.11

Posted: Thu Aug 02, 2012 4:08 pm
by hanover
Hi Carasmo

Works perfectly, absolutely fantastic.

Thank you so much.

Re: News: Field Definitions not working v 1.11

Posted: Thu Aug 02, 2012 9:52 pm
by carasmo
Cool. Now go and edit your original and stick a [solved] before it.