News module - displaying custom field in template

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
johnboyuk1
Forum Members
Forum Members
Posts: 235
Joined: Mon Nov 26, 2018 3:09 pm

News module - displaying custom field in template

Post by johnboyuk1 »

I'm sure this has been asked before - but I can't find it if it has! And I'm sorry if its a dumb question but its not mentioned in the module help (... it really should be!) but...

If I have created a custom field called 'image' which is of the 'linked file' type.. how do I display this in a News template? I had assumed something like

{$entry->image}

would do it but it doesnt...

thanks ...
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1800
Joined: Wed Feb 25, 2009 4:25 am

Re: News module - displaying custom field in template

Post by DIGI3 »

The sample templates give a good clue in how they show the custom fields, and the array is described in the "template help" page when in Design Manager (but yes, it probably could be referenced in the actual module help, too - this is an old module that needs a lot of love). Don't forget you can always do a <pre>{$entry|print_r}</pre> or <pre>{$entry->fields|print_r}<./pre> in your template to show everything you have available.

If you don't want to do a foreach like in the sample templates you can access them directly with:

Code: Select all

{$entry->fields.fieldname->value}
where fieldname is the name of your custom field.
Not getting the answer you need? CMSMS support options
johnboyuk1
Forum Members
Forum Members
Posts: 235
Joined: Mon Nov 26, 2018 3:09 pm

Re: News module - displaying custom field in template SOLVED

Post by johnboyuk1 »

Perfect - thanks!
Post Reply

Return to “CMSMS Core”