[SOLVED] Referencing associative arrays (spaces in keys) ...
Posted: Mon Dec 05, 2011 2:38 am
I use the following code to reference an associative array (in this case in the News module detail template):
However I am not able to use this syntax to reference another value where the key has a space in it, like:
Smarty throws an error in this case.
I've tried various tricks like:
- $entry->fields."Article Author"->value
- Assigning the key name to a variable and using eval
- Using capture to assign the variable value and then using eval
Does anyone know how this can be done in Smarty? Without this, the only way to access a custom field in the latest News module is to run a foreach loop and check for the name of the desired field - that seems long-winded.
TIA
-S
Code: Select all
$entry->fields.TestField->value
Code: Select all
$entry->fields.Article Author->value
I've tried various tricks like:
- $entry->fields."Article Author"->value
- Assigning the key name to a variable and using eval
- Using capture to assign the variable value and then using eval
Does anyone know how this can be done in Smarty? Without this, the only way to access a custom field in the latest News module is to run a foreach loop and check for the name of the desired field - that seems long-winded.
TIA
-S