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

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post 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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

Why not a regular Gallery tag with the variable where it needs to go..?
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

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

Post by Jo Morg »

Try:

Code: Select all

{Gallery dir="Portfolio/{$item->gallerydir}" template='RoyalSlider'}
It should work...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post 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. ;)
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

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

Post 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... ;)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Post Reply

Return to “Modules/Add-Ons”