#1 2016-02-09 22:13:20

From: Juiz de Fora / Brazil
Registered: 2015-06-08
Posts: 40

[GUIDE] ion:content strip tags helper

Sometimes a blog homepage can show a picture (cover) and the 1st paragraph of the content of the newests posts. In my case, the first paragraph of many posts are a image. So, I created a function in this helper file located in application/helpers/My_text_helper.php to strip the img tag from a paragraph, if there is one.

if ( ! function_exists('allowed_tags'))

	function allowed_tags($str, $tags = null)
		if ($tags){
			$arrayTags = explode("_", $tags);

			foreach ($arrayTags as $id=>$tag){
				$arrayTags[$id] = "<".$tag.">";

			$tags = implode("", $arrayTags);

		$str = strip_tags($str, $tags);

		return $str;

To use, call:

<ion:article:content paragraph="2" helper="text:allowed_tags:p_a" />

In this line, I said tags <p> and <a> area allowed. You can allow more tags, if it is necessary. If you use <img> the image will be returned.

Hope this can help somebody and if it is can be better or there is a another way to do it, please let me know!

Frederico Marinho - Social Media and Web Developer


#2 2016-03-23 19:17:31

Ionize Friend
From: Germany
Registered: 2010-09-20
Posts: 397

Re: [GUIDE] ion:content strip tags helper


Nice work, I will implement to the code in the future.

Best Regards,

Webdeveloper, Programmer, Application developer, Ionize friend


What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.


Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations