Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Variables in product descriptions?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-04-2012, 02:13 PM
 
JacksmithxD JacksmithxD is offline
 

X-Adept
  
Join Date: Oct 2010
Posts: 400
 

Talking 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!
__________________
Xcart 4.5.2
Reply With Quote
  #2  
Old 04-04-2012, 11:20 PM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #3  
Old 04-05-2012, 01:51 AM
 
JacksmithxD JacksmithxD is offline
 

X-Adept
  
Join Date: Oct 2010
Posts: 400
 

Default 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.
__________________
Xcart 4.5.2
Reply With Quote
  #4  
Old 04-05-2012, 02:41 AM
 
JacksmithxD JacksmithxD is offline
 

X-Adept
  
Join Date: Oct 2010
Posts: 400
 

Default 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
__________________
Xcart 4.5.2
Reply With Quote
  #5  
Old 04-05-2012, 05:03 AM
 
JacksmithxD JacksmithxD is offline
 

X-Adept
  
Join Date: Oct 2010
Posts: 400
 

Default Re: Variables in product descriptions?

Doesn't matter, decided to do something different, thanks anyways!
__________________
Xcart 4.5.2
Reply With Quote
  #6  
Old 04-05-2012, 11:50 PM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #7  
Old 04-19-2012, 11:59 AM
 
JacksmithxD JacksmithxD is offline
 

X-Adept
  
Join Date: Oct 2010
Posts: 400
 

Default 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.
__________________
Xcart 4.5.2
Reply With Quote
  #8  
Old 04-19-2012, 02:05 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default 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"}
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #9  
Old 04-20-2012, 02:15 AM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #10  
Old 04-20-2012, 02:29 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default 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.
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:30 PM.

   

 
X-Cart forums © 2001-2020