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

Smarty Variable printing

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-26-2009, 06:43 AM
 
roblen roblen is offline
 

Senior Member
  
Join Date: Oct 2004
Posts: 114
 

Default Smarty Variable printing

Hi I am trying to print from the 180th character position using the smarty truncate function. Can only get it to print from starting starting position and not starting from the middle of the string.

is there a way of doing this with truncate or is there a another function.?

{$product.descr|truncate:85} this prints the first 85 characters. I need to be able to print from starting to ending positions

in php i would use substr

thanks
rob
__________________
X-Cart version 4.1.9
PHP 5.2.13 Details >>
GD bundled (2.0.34 compatible)
MySQL server 5.0.77-log
MySQL client 5.0.77
Web server Apache/2.2
Operation system Linux
Perl not found
XML parser (expat) found
Reply With Quote
  #2  
Old 10-26-2009, 10:07 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default Re: Smarty Variable printing

see if this helps

http://www.smarty.net/manual/en/language.modifiers.php
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #3  
Old 10-26-2009, 10:48 AM
 
roblen roblen is offline
 

Senior Member
  
Join Date: Oct 2004
Posts: 114
 

Default Re: Smarty Variable printing

Thanks for your reply but i could not find the way to do it that way.
i added my code to the product.php page

### Split up product description
$desc1 = substr($product_info["descr"] , 0, 244);
$desc6 = substr($product_info["descr"] , 248,45);
$desc7 = substr($product_info["descr"] , 297,45);
$smarty->assign("desc1", $desc1);
$smarty->assign("desc6", $desc6);
$smarty->assign("desc7", $desc7);

##

rob.
__________________
X-Cart version 4.1.9
PHP 5.2.13 Details >>
GD bundled (2.0.34 compatible)
MySQL server 5.0.77-log
MySQL client 5.0.77
Web server Apache/2.2
Operation system Linux
Perl not found
XML parser (expat) found
Reply With Quote
  #4  
Old 10-26-2009, 03:43 PM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Re: Smarty Variable printing

Read that Smarty modifier page a little closer. All PHP functions are implicitly usable as Smarty modifiers. Try:

{$product.descr|truncate:244}
{$product.descr|substr:248:45}
{$product.descr|substr:297:45}
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #5  
Old 10-27-2009, 03:42 AM
 
roblen roblen is offline
 

Senior Member
  
Join Date: Oct 2004
Posts: 114
 

Default Re: Smarty Variable printing

Thank you. This is very useful to know.
rob
__________________
X-Cart version 4.1.9
PHP 5.2.13 Details >>
GD bundled (2.0.34 compatible)
MySQL server 5.0.77-log
MySQL client 5.0.77
Web server Apache/2.2
Operation system Linux
Perl not found
XML parser (expat) found
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 06:37 AM.

   

 
X-Cart forums © 2001-2020