If I create a custom field called "importance" for my news column, how can I get at that variable in the template?
I'm thinking something along the lines of:
{foreach from=$items item=entry}
{$entry|@print_r}
Importance: {$entry.fieldsbyname.importance.value}
{/foreach}
...but that doesn't work. The print_r statement shows the array, but what is the syntax for getting at specific elements?
Accessing news field definitions in template
[solved] Re: Accessing news field definitions in template
A friend of mine figured it out:
Importance: {$entry->fieldsbyname.importance->value}
Importance: {$entry->fieldsbyname.importance->value}
Re: Accessing news field definitions in template
Thx for posting this Thomas!!!!
Additional remark: if you use capitals in the Field Definition name, don't use them to call the value or it won't work...
Just letting everyone know to hopefully save someone somewhere some time
ex: I created the Field Definition "Comment"
Code that doesn't work
{$entry->fieldsbyname.Comment->value}
{$entry->fieldsbyname.Comment->name}
Code that works
{$entry->fieldsbyname.comment->value}
{$entry->fieldsbyname.comment->name}
Greetings,
Manuel
Additional remark: if you use capitals in the Field Definition name, don't use them to call the value or it won't work...
Just letting everyone know to hopefully save someone somewhere some time

ex: I created the Field Definition "Comment"
Code that doesn't work
{$entry->fieldsbyname.Comment->value}
{$entry->fieldsbyname.Comment->name}
Code that works
{$entry->fieldsbyname.comment->value}
{$entry->fieldsbyname.comment->name}
Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Re: Accessing news field definitions in template
If you only want to make the custom entries appear only when a value has been filled out, you may use one of the following methods:
Greetings,
Manuel
Code: Select all
{if $entry->fieldsbyname.comment != ''}A comment has been filled out{/if}
Code: Select all
{if isset($entry->fieldsbyname.comment)}A comment has been filled out{/if}
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Re: Accessing news field definitions in template
I was having some trouble getting the file location URL from the "fieldsbyname"
solution: use the generic file_location in combination with the fieldsbyname value
Greetings,
Manuel
solution: use the generic file_location in combination with the fieldsbyname value
Code: Select all
{$entry->file_location}/{$entry->fieldsbyname.record_cover_front->value}
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Re: Accessing news field definitions in template
If you use spaces in your Field Definition name, these should be replaced with underscores when calling the value etc...
Field Definition name: Record cover front
should become fieldsbyname.record_cover_front
Greetings,
Manuel
Field Definition name: Record cover front
should become fieldsbyname.record_cover_front
Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate