Page 1 of 1

News module - displaying custom field in template

Posted: Thu Sep 03, 2020 8:09 pm
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 ...

Re: News module - displaying custom field in template

Posted: Thu Sep 03, 2020 9:30 pm
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.

Re: News module - displaying custom field in template SOLVED

Posted: Fri Sep 04, 2020 7:45 am
by johnboyuk1
Perfect - thanks!