Page 1 of 1

[solved] Gallery call using a Smarty var in the dir param

Posted: Sat Apr 19, 2014 5:53 pm
by paulbaker
I have a ListIt2 instance in which there is a text input field "gallerydir" - this holds the directory name of a Gallery associated with the product, e.g. "Festival". I have created a Products template in which the idea is to show the Gallery for the particular product.

I am trying to do this with this in the template:

Code: Select all

{assign var="gallerycall" value="Gallery dir='Portfolio/`$item->gallerydir`' template='RoyalSlider'"} 

{eval var=$gallerycall}
This is simply printing Gallery dir='Portfolio/Festivalflavour' template='RoyalSlider' rather than evaluating it.

Summary: I am trying to "inject" the Smarty variable $item->gallerydir in to a Gallery call. How should I be doing it?

Thanks :D

Re: Gallery call using a Smarty variable in the dir paramete

Posted: Sat Apr 19, 2014 6:47 pm
by Dr.CSS
Why not a regular Gallery tag with the variable where it needs to go..?

Re: Gallery call using a Smarty variable in the dir paramete

Posted: Sat Apr 19, 2014 8:56 pm
by paulbaker
Thanks Dr.CSS.

When I put this in my template:

Code: Select all

{Gallery dir='Portfolio/$item->gallerydir' template='RoyalSlider'} 
{$item->gallerydir}
I get this output:

Code: Select all

<div class="gallery radius10">

</div>
 
Festivalflavour
i.e. an empty gallery div. You can see that $item->gallerydir is not being interpreted as a variable. But it is printing OK when you call it on the second line. Festivalflavour is definitely the correct name for the gallery directory.

Re: Gallery call using a Smarty variable in the dir paramete

Posted: Sat Apr 19, 2014 9:01 pm
by Jo Morg
Try:

Code: Select all

{Gallery dir="Portfolio/{$item->gallerydir}" template='RoyalSlider'}
It should work...

Re: Gallery call using a Smarty variable in the dir paramete

Posted: Sat Apr 19, 2014 9:12 pm
by paulbaker
ARGH!

Thank you so much Jo. That's it. 8)

I've been caught out by pesky single and double quotes before. :-[

I hope my public humiliation helps out someone in the future. ;)

Re: [solved] Gallery call using a Smarty var in the dir para

Posted: Sat Apr 19, 2014 9:41 pm
by Jo Morg
paulbaker wrote:I've been caught out by pesky single and double quotes before. :-[
Been there more often than I dare admit... ;)