1
bjuti
How to truncate string?
  • 2010/1/9 17:03

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


Hi Xoopsers...

I'm trying to add some SEO features in Classifieds 2.0RC2, so i've been editing index.php file like this:
$xoopsTpl->assign('desctext', $desctext);
$desctextclean = strip_tags($desctext, '<font><img><b><i><u>'); 
$xoopsTpl->assign('xoops_pagetitle',"$title $ctitle - $type");
$xoTheme->addMeta('meta', 'description', "$title $ctitle $type $price $typeprice $desctextclean|truncate:100:''");

All works ok, but I've tried to truncate $desctextclean to 100 chars, with no luck.

Any idea or help? (I'm not a programmer :) )

2
ghia
Re: How to truncate string?
  • 2010/1/9 19:20

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


|truncate:100:
That is a Smarty instruction to be used in templates.
You are dealing with PHP:
$xoTheme->addMeta('meta', 'description', "$title $ctitle $type $price $typeprice ".substr($desctextclean,0,100) );

3
bjuti
Re: How to truncate string?
  • 2010/1/10 0:00

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


Tnx Ghia :)

Soon I'll post hack for Classifieds in News :)