How to retreive custom field values in News module directly?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
10010110
Translator
Translator
Posts: 217
Joined: Tue Jan 22, 2008 9:57 am

How to retreive custom field values in News module directly?

Post by 10010110 »

I have a custom field in my News module called “Publication/medium”, and I want to display the value of this field in a custom location in my summary template, i. e. outside of the foreach loop in which the custom fields are usually retreived. How would I have to go about this?

I tried {$entry->fields.Publication/medium->value} as well as {$entry->fields.Publication/medium.value} but nothing is working. :-(
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: How to retreive custom field values in News module direc

Post by Jo Morg »

http://forum.cmsmadesimple.org/viewtopi ... es+in+News
Search still works for me :)...
BTW where does the / comes from?
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
chandra

Re: How to retreive custom field values in News module direc

Post by chandra »

A slash is not allowed inside var name.
10010110
Translator
Translator
Posts: 217
Joined: Tue Jan 22, 2008 9:57 am

Re: How to retreive custom field values in News module direc

Post by 10010110 »

The slash is part of the field name. There is only the option of giving the field a name (i. e. there is no alias field or whatever), and apparently it’s possible to put any character in the name field. So, how is the field retreived then if not by name? The characters are probably escaped somehow, no?

And by the way: how comes this thread is in the lounge? Has it been moved? Because I was sure I posted it in the Product Support forum.
I’m probably working way too much, I can’t even think straight anymore.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: How to retreive custom field values in News module direc

Post by Jo Morg »

If the / is acceptable (which I'm not sure) this should work afaik:

Code: Select all

{$entry->fieldsbyname.Publication/medium->value}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
chandra

Re: How to retreive custom field values in News module direc

Post by chandra »

Smarty follows the php naming rules for variables

http://php.net/manual/en/language.variables.basics.php

As you can see slash is not allowed. A slash is reserved as separator between folders ;).
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: How to retreive custom field values in News module direc

Post by Dr.CSS »

Most likely it was moved from product support because you were asking about a 'module' not the core, even if News comes pre-installed...
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: How to retreive custom field values in News module direc

Post by Rolf »

I moved the thread to Modules/Add-Ons board
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Post Reply

Return to “Modules/Add-Ons”