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 Variable printing (https://forum.x-cart.com/showthread.php?t=50381)

roblen 10-26-2009 06:43 AM

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

amy2203 10-26-2009 10:07 AM

Re: Smarty Variable printing
 
see if this helps

http://www.smarty.net/manual/en/language.modifiers.php

roblen 10-26-2009 10:48 AM

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.

geckoday 10-26-2009 03:43 PM

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}

roblen 10-27-2009 03:42 AM

Re: Smarty Variable printing
 
Thank you. This is very useful to know.
rob


All times are GMT -8. The time now is 06:09 AM.

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