![]() |
Using Smarty or PHP in cateogry descriptions to reference language strings
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:
{php} echo '$lng.lbl_my_text'; {/php} |
Re: Using Smarty or PHP in cateogry descriptions to reference language strings
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:
if ($current_category['description'] != '') |
Re: Using Smarty or PHP in cateogry descriptions to reference language strings
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?
|
Re: Using Smarty or PHP in cateogry descriptions to reference language strings
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`} |
Re: Using Smarty or PHP in cateogry descriptions to reference language strings
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 |
Re: Using Smarty or PHP in cateogry descriptions to reference language strings
Quote:
Anybody have any ideas on how to do what is described above? Thanks! |
Re: Using Smarty or PHP in cateogry descriptions to reference language strings
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:
|
All times are GMT -8. The time now is 07:59 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.