'print_r' in a tpl template??

rsoul
rsoul's picture

Joined: 2006-01-27
Posts: 6
Posted: Thu, 2006-02-09 20:55

Hi all,
This may be a simple question, don't know, can't find an answer anywhere!

How can call the equivalent of php's print_r() function on a Smarty variable??

i.e. from the album.tpl there is a line:

{foreach from=$theme.children item=child}

I want to examine ALL the properties of the object 'child' (I'm trying to find out at that level what 'type' the child is, i.e. image, audio etc.....

A simple thing from my php experience would be print_r( $child ) but of course php doesn't know about the $child variable! What is the smarty equivalent? any ideas?

OR, and other cool way to find out the attributes of that object at this level?

Thanks in advance!
Cheers,
R.Soul.

 
Photographicon
Photographicon's picture

Joined: 2006-01-05
Posts: 40
Posted: Fri, 2006-02-10 00:49

{$child|print_r} should do that... see http://codex.gallery2.org/index.php/Gallery2:Tpl_Reference

LITL.W/L
Dominic.

 
rsoul
rsoul's picture

Joined: 2006-01-27
Posts: 6
Posted: Fri, 2006-02-10 02:12

Great thanks - I knew there was a way! However, I notice that prints out the VALUES of the array but not the key names (listtags) - is there a way to tell print_r to show the values AND the tags, just like in php?

thanks again.

 
Photographicon
Photographicon's picture

Joined: 2006-01-05
Posts: 40
Posted: Fri, 2006-02-10 03:23

Not sure how to do this for a single array, but turning on the Gallery debug feature will dump all variables and show key/value pairs for arrays. Do one of:

* edit /config.php - change "$gallery->setDebug(false);" to "$gallery->setDebug('buffered');"
* insert {g->debug} in your template just after the variable you want to monitor has been set.

The former will give you more subsidiary information, the latter will give you more control over when the debug dump occurs.

LITL.W/L
Dominic.