I have experienced a great issue when users CAN add some HTML tags to story content. The problem is that if html tags are used and story content is cutted to 165 characters, there will NOT be endtags.
What does it mean practically?
Big problem. Not only page is not valid, every story content will be then bold,italic or underlined also (depends on allowed tags).
Solution:
1) Disallow HTML tags in story.
2) Use my new hardcoded update.
It is funny that original idea was pretty simple but this is quite difficult because we need alternative story content with closed html tags.
Update:
Replace original code in link.php
PHP Code:
// if link content < 160 chars then no "MORE" link
if (strlen($this->content)>165){
$smarty->assign('long_content',true);
}
// end
with
PHP Code:
//*********************************************************************
//READ MORE ADDON START
// if link content < 160 chars then no "MORE" link
if (strlen($this->content)>165){
//find if text has unclosed tags
$cutted_content= utf8_substr($this->content,0,165);
//shortest tag can be at least 3 chars long
for ($i=0 ; $i<strlen($cutted_content)/3 ; $i++) {
//find html tag if previous tag position number was lower
if ($gtpos <= $i*3) {
$ltpos=stripos($cutted_content,"<",$i*3);
$gtpos=stripos($cutted_content,">",$i*3);
}else {
$ltpos=stripos($cutted_content,"<",$ltpos+1);
$gtpos=stripos($cutted_content,">",$gtpos+1);
}
//if tag was detected
if ($ltpos>-1 && $gtpos>-1){
$tag=substr($cutted_content,$ltpos+1,$gtpos-$ltpos-1);
// exclude empty tags and end tags
if(strlen($tag)>0 && substr($tag,0,1)!="/"){
$count[$tag]++;
$tagname[]=$tag;
}
}else {
//no more tags, no more cycles needed
break;
}
}
//check if tag has its own closetag
if ($tagname) {
$origtext=$cutted_content;
foreach ($tagname as $tagn) {
$cltag=stripos($origtext,"</$tagn>");
if ($cltag ==false){
$addclosetags[]="</$tagn>";
}else {
$origtext = substr($origtext,0,$cltag).substr($origtext,$cltag+strlen("</$tagn>"));
}
}
if ($addclosetags){
$addclosetags= array_reverse($addclosetags);
$updated_content=$cutted_content;
foreach ($addclosetags as $at){
$updated_content .=$at;
}
$smarty->assign('updated_content',$updated_content);
$smarty->assign('add_closetags',true);
} //update v 0.2
}
$smarty->assign('long_content',true);
}
//READ MORE ADDON END
//**********************************************************************
Now open link_summary.tpl in your templates/yget/ folder and find
Code:
{if $show_content neq 'FALSE'} ...something...{/if}
Replace it with:
Code:
{if $show_content neq 'FALSE'}
{if $add_closetags eq true}
{if $pagename neq "story"}
{$updated_content}
{else}
{$story_content}
{/if}
{else}
{$story_content}
{/if}
Now everything should work smoothly