function chopShort($length, $buttonlanguage = "Read More →") { // Removes HTML and HCd inserted photos and galleries, and breaks on a space. It adds a link at the end of the string as well for a “Read More”. $content_to_chop = $this->get_content(); if (strlen($content_to_chop) > $length) { $content_to_chop = strip_tags($content_to_chop); $content_to_chop = scrub_HCd_Tags($content_to_chop); $content_to_chop = substr($content_to_chop, 0, strpos($content_to_chop, " ", $length)); $content_to_chop .= "... <a class=\"readmore\" href=\"" . get_link(BLOG_STATIC_AREA . "/view/{$this->id}/{$this->slug}") . "\">{$buttonlanguage}</a>\n"; } return $content_to_chop; }
function chopText($content, $charcount, $stopchar = " ") { // This function is needed to scrub content of the HCd backend tags as well as HTML tags. // Can be used on events, pages, whatever... // The Blog model also has one called "chopForBlogDigest" and "chopShort" which works well for Blog entries // Remove HCd tags $content = scrub_HCd_Tags($content); // Scrub HTML (to remove long <a href> urls) and THEN truncate the text. $content = strip_tags($content); if (strlen($content) > $charcount) { // Use the $stopchar to find out where to truncate the text. Use "</p>" if you want to go to the end of the next paragraph $content = substr($content, 0, strpos($content, $stopchar, $charcount)); } return $content; }