Page 1 of 1

How can i edit this function to now show html tags?

Posted: Wed Sep 16, 2009 11:49 am
by php1016
Hello, im new to php programming and i want to know what the result would be if i removed "strip_tags" from line 4. What i would want to happen is that it would now show the html tags. Could someone show me the exact code that would allow me to now use html tags for the function on line 4? thank you, any help appreciated.

Code: Select all

// start mod: Product Captions (Short Descriptions)
// by Estelle (http://cubecart.expandingbrain.com)
if (!empty($productResults[$i]['short_description'])) {
 $view_cat->assign("TXT_DESC",strip_tags($productResults[$i]['short_description']));
} else {
 $view_cat->assign("TXT_DESC",substr(strip_tags($productResults[$i]['description']),0,$config['productPrecis'])."…");
}
// end mod: Product Captions (Short Descriptions)
 

Re: How can i edit this function to now show html tags?

Posted: Wed Sep 16, 2009 11:52 am
by Mirge

Re: How can i edit this function to now show html tags?

Posted: Wed Sep 16, 2009 11:55 am
by superdezign
Because there is an inflexible call to substr(), removing strip_tags() gives you the possibility of breaking your content in the middle of a tag. This would cause something like this to happen:

If your raw data is:

Code: Select all

Our brand new product is <b>amazing!!</b>
If $config['productPrecis'] is 41, you would get:
Our brand new product is amazing!!
But if $config['productPrecis'] is 40, then you would get
Our brand new product is amazing!!</b

Re: How can i edit this function to now show html tags?

Posted: Fri Sep 25, 2009 2:06 pm
by php1016
Thanks for the replies.

Ive tested this by removing strip_tags from line 4 and it seems to work ok so far.

superdezign - I have not run into that yet. I will do some testing. thank you.