Blesta Addons Posted August 24, 2014 Report Share Posted August 24, 2014 the class data_structure_string.php has already the option to truncate a text , but is not supporting a HTML out put . so 'im requesting adding a new function to truncate a HTML response/output . Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted August 25, 2014 Author Report Share Posted August 25, 2014 i have completed this task my self , now is time to sharephp class to truncate HTML content , https://github.com/Blesta-Addons/data_structure_html INSTALLATIONjust upload the helpers folders to the blesta directory .USAGEinside the controller add : $this->set("html", $this->DataStructure->create("html")); in the template file .PDT you can use it as the fallowing code $result = $html->truncate($text, $length = 150 , $strip_tags = true , $ending = ' ... ', $exact = false, $considerHtml = true ); you can sipmly you it as $result = $html->truncate($this->Html->ifSet($vars->text), 180 ); the class support the fallowing param@param string $text HTML to truncate.@param integer $length Length of returned string, including ellipsis.@param boolean $strip_tags If true , $text will rendered without html tags@param string $ending Ending to be appended to the trimmed string.@param boolean $exact If false, $text will not be cut mid-word@param boolean $considerHtml If true, HTML tags would be handled correctlythis class is taken from the CakePHP framework . Michael 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.