| ||||||||||
| Shopping cart software Solutions for online shops and malls | ||||||||||
|
|
||||||||||
| X-Cart Home |
Using Smarty or PHP in cateogry descriptions to reference language strings | |||
![]() |
|
||
|
|
Thread Tools | Search this Thread |
|
#1
|
|||||||
|
|||||||
|
Hi. I want to be able to include a language referecne in my category descriptions. For example I would like to put "$lng.lbl_my_text" in the description tag.
I've thought of doing this a couple ways but neither work. Does anyone know how I can do this. Here are the ways I've tried it: Var only: PHP Code:
PHP: PHP Code:
Smarty: Code:
__________________
-Chad |
|||||||
|
#2
|
|||||||||
|
|||||||||
|
It won't work since smarty tags won't be processed. You'd probably have to set a variable in your text like ##yourvariable## and then in your home.php file use something like:
Code:
|
|||||||||
|
#3
|
|||||||
|
|||||||
|
Thanks for the info. Would it make the most sense to do this in the PHP file for home.php or should I do this in the TPL files? Probably the home.php.... right?
__________________
-Chad |
|||||||
|
#4
|
|||||||||
|
|||||||||
|
Usually best to put any php processing into the php file, but you could do something this in smarty everywhere the description is used in tpl files (i.e. skin1/customer/main/subcategories.tpl}:
{$current_category.description|replace:"##variable ##":`$lng.lbl_my_text`} |
|||||||||
|
#5
|
|||||||
|
|||||||
|
Quote:
Is there a way to make this a little smarter? So I don't have to put an IF statement for each $lng VAR? Could it somehow evaluate the ##yourvariable## and attached it to $lng.yourvariable ? Would that be some kind of eval function? Thanks for the help. Thanks, Chad
__________________
-Chad |
|||||||
|
#6
|
|||||||
|
|||||||
|
Quote:
Anybody have any ideas on how to do what is described above? Thanks!
__________________
-Chad |
|||||||
|
#7
|
|||||||
|
|||||||
|
I figured it out. It's a bit more dynamic this way. This will work for current_category descriptions that have one var defined in them as ##VAR##. put this in the home.php along with the other smarty assigns. you'll need to change the smarty var reference in your tpl to this new one.
PHP Code:
__________________
-Chad |
|||||||
|
|
|||
|
X-Cart forums © 2001-2020
|
|||