Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Smarty variable indexed by string question

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-19-2013, 07:05 AM
 
DavyMac DavyMac is offline
 

eXpert
  
Join Date: Apr 2007
Location: Poole, UK
Posts: 333
 

Default Smarty variable indexed by string question

This is a problem with understanding how smarty works:

I have a variable array $banner_code where $banner_code.$pos returns a string "x_marks_the_spot".

This string is then used to identify a variable set in php called $x_marks_the_spot.

My question is given only $banner_code.$pos how do I write to the contents of $x_marks_the_spot?

**** If only I could code this: {$"{$banner_code.$pos}"="xyz"}
__________________
X-Cart GOLD Plus v4.5.4
CDSEO Pro
ewdhosting Dedicated Server
Dedicated SSL
Stone Edge OM
Reply With Quote
  #2  
Old 11-19-2013, 08:40 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Smarty variable indexed by string question

{assign var="x_marks_the_spot" value=$banner_code.$pos}

$x_marks_the_spot can now be used in the template.

Yes?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #3  
Old 11-19-2013, 12:03 PM
 
DavyMac DavyMac is offline
 

eXpert
  
Join Date: Apr 2007
Location: Poole, UK
Posts: 333
 

Default Re: Smarty variable indexed by string question

Quote:
Originally Posted by carpeperdiem
Yes?
No!

I actually need to be able to write {${$banner_code.$pos}} but nested '{' are only allowed in smarty 3: example


It would appear the only way I can achieve what I am looking for is to include a php block or call a smarty pluggin, which I'm not going to do.

Thanks David
__________________
X-Cart GOLD Plus v4.5.4
CDSEO Pro
ewdhosting Dedicated Server
Dedicated SSL
Stone Edge OM
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:09 AM.

   

 
X-Cart forums © 2001-2020