Page 1 of 1

[Solved] How can I call news module custom fields?

Posted: Thu May 29, 2014 12:42 pm
by Torpedine
I need to call the custom fields in the news module templates, but {$entry->fieldname} does not work. How can I do it?

Thanks in advance

Re: How can I call new module custom fields?

Posted: Thu May 29, 2014 12:56 pm
by Jo Morg
I think it changed to {$entry->fields.fieldname}.
As usual you can find what is available with {get_template_vars} and {$<whatervervarname>|print_r}.
I believe {$entry->fields|print_r} will give some clues to what you need.
HTH.

Re: How can I call new module custom fields?

Posted: Thu May 29, 2014 1:43 pm
by Torpedine
I tried {$entry->fields.fieldname} - Using the field name {$entry->fields.Provincia}, but the output is a non formatted page without template...

Re: How can I call new module custom fields?

Posted: Thu May 29, 2014 2:32 pm
by Jo Morg
Sorry my bad... try {$entry->fields->Provincia}. This syntax worked on a test I just did.

Re: How can I call new module custom fields?

Posted: Thu May 29, 2014 5:47 pm
by Torpedine
It seems I cannot display anything.
I tried {$entry->fields->fieldname} but nothing is displayed. I tried with the capitalised version of the field (Provincia) and the uncapitalised one (provincia)

Re: How can I call new module custom fields?

Posted: Thu May 29, 2014 5:52 pm
by Jo Morg
What template are you using? Summary? Detail?

Re: How can I call new module custom fields?

Posted: Thu May 29, 2014 6:46 pm
by Torpedine
Summary, but I have to do something similar also in detail

Re: How can I call new module custom fields?

Posted: Thu May 29, 2014 7:10 pm
by Jo Morg
My 1st answer was almost correct:

Code: Select all

{$entry->fields.Provincia->value}
I was in a bit of a hurry when I replied before, sorry. This should work in both templates, in the summary template it has to be inside the foreach loop that iterates through all the entries.
If you use {$entry->fields.Provincia|print_r} you will see how to call the other components of the field.

Re: How can I call news module custom fields?

Posted: Fri May 30, 2014 11:07 am
by Torpedine
Thank you! It works perfectly!
It should be put in the module help...

Re: [Solved] How can I call news module custom fields?

Posted: Fri May 30, 2014 11:13 am
by Jo Morg
Torpedine wrote:It should be put in the module help...
The sample templates do have a very comprehensive help text in Smarty comments. May not be easy at 1st but it's all there and once you find your bearings it's not that difficult.