pembrock pembrock - 6 months ago 114
Smarty Question

Using php class property in smarty template

Can i use php class static properties in smarty template?
For example:

class UserData
{
const INDEX = 1;
const STREET = 2;

static public $_address_fields = array(
self::INDEX,
self::STREET
);
}


And in my smarty template i want do something like this:

{UserData::$_address_fields}


Is it possible?

Answer Source

You should be able to pass this in from your controller?

For example: $smarty->assign('AddressFields, UserData::$_address_fields);

This should then be avilable for use in your template like so: {$AddressFields}

Smarty Docs: https://www.smarty.net/docsv2/en/api.assign.tpl

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download