![]() |
Nesting Smarty in PHP in Smarty - really
I'm working on a project where I'm using PHP in my Smarty templates. That works fine - I just use:
{php} But now I need some Smarty variables in my PHP functions. So I need to escape back to Smarty, or assign the variables earlier in Smarty and call them from within PHP. Is there a way to do this? |
I think that you may be looking at it the wrong way. If you need a value from a Smarty variable, most likely you derived that value from variables that are being passed by a PHP file somewhere. In that case then just take the same action in your PHP file to arrive at this same value.
For instance, you have a Smarty variable that you add "2" to it and get a new value. In your PHP file, just take the variable that was passed to Smarty and take the same action. The second case is that the value may be stored in a variable from a user input form. These forms should be processed by PHP code anyway, so that variable or value should be available to you. |
This makes good sense.
The variables I'm trying to use are derived from SQL databases for orders. For example, I need the SKU, which in Smarty is: {$products[product].productcode} So do you know what the PHP variable that I'd use for that is? Is there a file in X-Cart that assigns all of these? Thanks! |
All times are GMT -8. The time now is 09:33 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.