Accessing Smarty arrays

swift
swift's picture

Joined: 2003-12-08
Posts: 39
Posted: Tue, 2007-02-27 16:37

I want to get the width of the item's imageFrame in my theme's Album template (album.tpl), so the way I thought to do it was something like:

{$ImageFrameData.data.`$theme.albumFrame`.widthRR}

in this case, $theme.albumFrame = shadow, so what I want to get is the value of $ImageFrameData.data.shadow.widthRR, which is 7

I've tried everything I can think of, square-brackets and back-quotes in every combination, but I can't get the value, only a text string that is partly evalualted (eg Array.data.shadow.widthRR).

Any ideas? I assume I can do this in PHP, but everyone says to try to keep PHP out of the .tpl files, and this doesn't seem like it should be that hard to do....

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2007-02-27 20:00

you need to know the name of the frame you are uisng for that album or assign a smarty variable to it I guess (not positive)

{$ImageFrameData.data.AlbumWarmGilt.widthRR}
where AlbumWarmGilt is the name of the album.
Turn debug on to 'buffered' and you will see the smarty variables available in the smarty pop up window.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
swift
swift's picture

Joined: 2003-12-08
Posts: 39
Posted: Wed, 2007-02-28 13:12

I don't want to hard-code the imageFrame name into the smarty call, I'm looking to make something work for any frame used. I know how to get the frame name ($theme.params.albumFrame), my questions is how can I then use this in the call to get the width of the frame. In PHP you can do something like $array[$key_name] where $key_name is a variable containg the name of the array key you want to access, but I can't figure out how to do a similar thing with Smarty...

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2007-02-28 14:52

does {$ImageFrameData.data.$theme.params.albumFrame.widthRR} work?

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
swift
swift's picture

Joined: 2003-12-08
Posts: 39
Posted: Wed, 2007-02-28 16:02

I just found a solution to this, not what you proposed though: The way to do it is to split it into 2 calls -

{assign var=frameType value=$theme.params.albumFrame}
{assign var=cellWidth value=$ImageFrameData.data.$frameType.widthRR}

I had thought I'd tried something like that before, but I guess not... Oh well, problem solved

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2007-02-28 17:53

That was my next attempt but you beat me to the punch. Glad you got it sorted and thanks for posting the solution.