View Single Post
  #12  
Old 12-20-2012, 11:29 AM
 
hooter hooter is offline
 

X-Adept
  
Join Date: Dec 2004
Posts: 519
 

Default Re: Dynamic Image Directory Reference from within Langauge Variable

Alternatively and possibly simpler solution would be:
Language variable would contain this exactly as Steve suggested:
Code:
<a href="home.php"><img src="{$AltImagesDir}/custom/mypicture.jpg" /></a>

Then call the language variable in your tpl file thusly:
Code:
{eval var=$lng.languagevariablename}

Essentially you can treat a variable as a template and embed entire smarty constructs within then using eval function outputs the variable contents.

Quote:
Originally Posted by tartaglia
So here's the result...

Sorry Steve your suggestion...
Code:
<a href="home.php"><img src="{$AltImagesDir}/custom/mypicture.jpg" /></a>
doesn't work, but thanks.

What does work is...
Code:
<a href="home.php"><img src="{{AltImagesDir}}/custom/mypicture.jpg" /></a>

if you call it like this from the tpl file...
Code:
{$lng.languagevariablename|substitute:"AltImagesDir":$AltImagesDir}

I believe this is because the language variable itself can't pass through the real value of the smarty variable. Therefore they use the {{ }} to identify a value that can be called out by the substitute function and in the substitute function they replace the AltImagesDir with the smarty variable {$AltImagesDir} which of course the tpl file know.

There ya go, it works now. All that to avoid hardcoding the path in the language variable, not sure it was worth it but a good learning exercise. Feel free to give a more proper explanation of why it works if you want. I am not a developer.
__________________
Blog for X-Cart | Ebay Auction Manager
Reply With Quote