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)
-   -   Variables in product descriptions? (https://forum.x-cart.com/showthread.php?t=63173)

JacksmithxD 04-04-2012 02:13 PM

Variables in product descriptions?
 
Saw a similar thread for very low x-cart versions around 2007.

Can this be done for 4.4.4? I would absolutely love it if it can be done.

That way I can create a template using the smarty code for my product descriptions, saving me hours and hours of work.

e.g {$product.product} and {if $main eq "manufacturers} etc

Someone please shed light on this! :D

vasilis 04-04-2012 11:20 PM

Re: Variables in product descriptions?
 
Yes, it can be done, using the Webmaster mode, in which you can view the templates involved in the rendering of each page, also can click on the 'Show Variables' button of the webmaster mode popup window, in which section you can view all the smarty variables and their content.

JacksmithxD 04-05-2012 01:51 AM

Re: Variables in product descriptions?
 
Quote:

Originally Posted by vasilis
Yes, it can be done, using the Webmaster mode, in which you can view the templates involved in the rendering of each page, also can click on the 'Show Variables' button of the webmaster mode popup window, in which section you can view all the smarty variables and their content.


That's good to know, but how can I allow smarty variables to go in product descriptions? As they dont show up inside.

JacksmithxD 04-05-2012 02:41 AM

Re: Variables in product descriptions?
 
I've tried a few ways of doing this but it doesn't work e.g

<td class="descr">{$product.fulldescr|default:$product .descr}</td>
changed to
<td class="descr">{eval var=$product.fulldescr|default:$product.descr}</td>

Anyone got a suggestion?

Editing skin/common_files/customer/main/product_details.tpl

JacksmithxD 04-05-2012 05:03 AM

Re: Variables in product descriptions?
 
Doesn't matter, decided to do something different, thanks anyways! :)

vasilis 04-05-2012 11:50 PM

Re: Variables in product descriptions?
 
How come
Code:

{$product.fulldescr|default:$product.descr}
doesn't work? That's the general syntax for displaying smarty variable content. For example, '$product' is an array and 'fulldescr' is one of it's elements listed under '$product' in the debug window variables section.

JacksmithxD 04-19-2012 11:59 AM

Re: Variables in product descriptions?
 
I can do it on the code itself it works fine, I just wanted to be able to do it via product description e.g using xcart admin to edit a product description,, hope that makes sense. :)

cherie 04-19-2012 02:05 PM

Re: Variables in product descriptions?
 
Not sure if this is what you are looking for. You could try using substitute. Just a thought as I haven't actually tried it in the description:

"This is my {{adjective}} description is."

{$product.descr|substitute:"adjective":"amazing"}

vasilis 04-20-2012 02:15 AM

Re: Variables in product descriptions?
 
I have tried this, and it worked (using the 'replace' smarty modifier):
(the following code is used inside any template file that displays the product description)
Code:

{assign var="varname" value=$some_variable}{$product.descr|amp|replace:'<placeholder>':$varname}
In other words, you insert a placeholder inside the description of the product and it gets replaced by a variable value.

ADDISON 04-20-2012 02:29 AM

Re: Variables in product descriptions?
 
This is a very good question. You want in your Admin -> Product page to use in product short or full description any kind of variables (XC variables or your own). For language labels I can confirm that eval() function works.

http://forum.x-cart.com/showthread.php?t=57707&highlight=eval
http://forum.x-cart.com/showthread.php?t=44405&highlight=eval

Till now I did not think using other variables in product description, just static text.


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

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