X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Smarty Assign Problem (https://forum.x-cart.com/showthread.php?t=57500)

adam.fearn 01-13-2011 03:20 AM

Smarty Assign Problem
 
I'm editing the products.php file in the cart root directory and have been having some issues outputting variables and the like in the products list.

For testing, in products.php, I have put the folowing:

PHP Code:

$foo 'BAR';
$smarty->assign('foo' $foo); 


Right at the bottom, with the other smarty assigns, then in skin/common_files/customer/main/products_list.tpl, I have put the following:

PHP Code:

{$foo


Right next to where the price is displayed, but alas, nothing shows up. It does not output anywhere on the page at all.
Am I doing something wrong? Can anyone suggest any solutions? I'd appreciate it.

Regards,

- Adam.

qualiteam 01-13-2011 04:18 AM

Re: Smarty Assign Problem
 
You should make sure that you are editing the right template.

skin/common_files/customer/main/products_list.tpl

The common_files are used if a skin has no specific template... e.g. fashion_mosaic_blue has its own template:
skin/fashion_mosaic_blue/customer/main/products_list.tpl

Thus the directory in green should be the active skin.

adam.fearn 01-13-2011 05:05 AM

Re: Smarty Assign Problem
 
Thank you for your response.

I am currently using the 3-column template, which has only a couple of files in its directory.

I have edited the products_list.tpl before (to change the "Our Price" text to static text just for that page) and it worked fine, I have also used the {$product.productid} Smarty code in the same file to display the product's ID next to its name (merely as a test) and that has worked too.

I am pretty sure I'm editing the correct file, is there any thing else that may be causing the problem?

Kind Regards,

- Adam.

cflsystems 01-13-2011 05:07 AM

Re: Smarty Assign Problem
 
you may need to clear the cache - cleanup.php

adam.fearn 01-13-2011 05:17 AM

Re: Smarty Assign Problem
 
I have done that once or twice, just did it again to make sure and it's still the same.

Seeing as the $foo variable is set in products.php, shouldn't I be able to see it in the debug window in Webmaster Mode, whether it's being echo'd or not? As I don't see it in there either.

Regards,

- Adam.

qualiteam 01-13-2011 05:26 AM

Re: Smarty Assign Problem
 
Another possible reason is that the variable appears in the code fragment that is not logically "active" on that page.

Have you tried inserting it at the beginning or at the very end of the template?

adam.fearn 01-13-2011 07:37 AM

Re: Smarty Assign Problem
 
Thanks for your help, qualiteam. Greatly appreciated.
I have resolved this issue now and evrything seems to be in order. :)

qualiteam 01-13-2011 09:03 PM

Re: Smarty Assign Problem
 
I'm glad you've found the solutions provided useful.

Thank you.


All times are GMT -8. The time now is 08:47 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.