SMARTY "Namespacing" for custom fields
Posted: Sat Aug 29, 2009 1:49 am
Many of the modules permit custom fields. Here is a way to convert your fieldnames into Smarty variables without creating conflicts with other template vars having the same variable name.
This example is from CGUserDirectory, but you can use the same technique for any of the modules with custom fields.
What this did was concatenate "ud_" onto the beginning of each variable name. You can use whatever prefix you want.
Example: If your custom field was named "alias" you can now call it with {$ud_alias}
This example is from CGUserDirectory, but you can use the same technique for any of the modules with custom fields.
Code: Select all
{foreach from=$users item='oneuser'}
{* properties *}
{foreach from=$oneuser.properties item='onepropvalue' key='propname'}
{assign var="ud_"|cat:$propname value=$onepropvalue}
{/foreach}
Example: If your custom field was named "alias" you can now call it with {$ud_alias}