[SOLVED] Get and display variables from objects / arrays with smarty
Posted: Thu Apr 08, 2010 12:09 am
I am having a tough time trying to extract variables from an array within an object. I am hoping that someone can help me figure out my issue and give me a quick run-down on how this to properly output variable values.
After doing a print_r dump of the Products object (I am working with the Products Module), I find the variable I am looking for and see the correct value.
In a node in $Products->cms->siteprefs, I find: [Products_mapi_pref_autopreviewimg] => 0
Outputs: Nothing
Outputs: 1 even though the value is 0
Outputs: nothing
Just for kicks, I tried to access some other variables in the same object. Many of them behaved the same way, but some outputted the value correctly, like {$Products->cms->db->username}. This has me completely confused ???, and I would much appreciate a lesson in smarty / objects :D.
Versions:
After doing a print_r dump of the Products object (I am working with the Products Module), I find the variable I am looking for and see the correct value.
In a node in $Products->cms->siteprefs, I find: [Products_mapi_pref_autopreviewimg] => 0
Code: Select all
{$Products->cms->siteprefs->Products_mapi_pref_autopreviewimg}
Code: Select all
{$Products->cms->siteprefs->Products_mapi_pref_autopreviewimg|print_r}
Code: Select all
{$Products->cms->siteprefs->Products_mapi_pref_autopreviewimg->value}
Just for kicks, I tried to access some other variables in the same object. Many of them behaved the same way, but some outputted the value correctly, like {$Products->cms->db->username}. This has me completely confused ???, and I would much appreciate a lesson in smarty / objects :D.
Versions:
- CMSMS: 1.6.7 "Teremba Bay"
- PHP: 5.2.11
- Apache: 2.0.63
- Products: 2.4.8
- CGExtensions: 1.17.8
- CGSimpleSmarty: 1.4.3