[solved] News: Field Definitions not working v 1.11

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
hanover
Forum Members
Forum Members
Posts: 14
Joined: Fri Jul 13, 2012 8:26 am

[solved] News: Field Definitions not working v 1.11

Post 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}
Last edited by hanover on Fri Aug 03, 2012 6:45 am, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: News: Field Definitions not working v 1.11

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
hanover
Forum Members
Forum Members
Posts: 14
Joined: Fri Jul 13, 2012 8:26 am

Re: News: Field Definitions not working v 1.11

Post by hanover »

Hi Calguy
Thank you for the reply. I am not an expert, is it possible for you to show an example?
hanover
Forum Members
Forum Members
Posts: 14
Joined: Fri Jul 13, 2012 8:26 am

Re: News: Field Definitions not working v 1.11

Post 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"
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: News: Field Definitions not working v 1.11

Post 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.
hanover
Forum Members
Forum Members
Posts: 14
Joined: Fri Jul 13, 2012 8:26 am

Re: News: Field Definitions not working v 1.11

Post by hanover »

Hi Carasmo

Works perfectly, absolutely fantastic.

Thank you so much.
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: News: Field Definitions not working v 1.11

Post by carasmo »

Cool. Now go and edit your original and stick a [solved] before it.
Post Reply

Return to “CMSMS Core”