Hi,
I am having a hell of a time rendering a $Title variable in the template which contains HTML. Somewhere between the controller and the template
< and >
are being replaced with < and >
as well as many other characters. I've tried absolutely everything to prevent this and to re-replace them but to no avail. The title is plain text in the database, but I have some titles which are Tweets, and so in the controller, in my DataObject::get() result I am parsing them to change the parts that are supposed to be links into links. They come back from the parser perfectly:horngroup: <a href="http://twitter.com/#!/search?q=%23Apple" target="_blank">#Apple</a> Announces A $499 Retina-Equipped <a href="http://twitter.com/#!/search?q=%23iPad" target="_blank">#iPad</a> (It’s Just Called iPad) <a href="http://t.co/cFPe1HPg" target="_blank">http://t.co/cFPe1HPg</a> <a href="http://twitter.com/#!/search?q=%23appleevent" target="_blank">#appleevent</a>
But when I render $Title in the template, it looks like this:
horngroup: <a href='http://twitter.com/#!/search?q=%23Apple' target='_blank'>#Apple</a>’s new <a href='http://twitter.com/#!/search?q=%23iPad' target='_blank'>#iPad</a>: 9 features that matter <a href='http://t.co/IOwFyCii' target='_blank'>http://t.co/IOwFyCii</a>
First of all, why is this happening, and second, how can I stop it? It seems I need a method ion the template itself to render it as HTML but I can't figure it out. Any help out there?
$stream_items = DataObject::get($table,
"`Category`.`CategoryFilterURL` = '".$url."'","Date DESC",
"LEFT JOIN `".$table."_Categories` ON `".$table."_Categories`.`".$table."ID` = `".$table."`.`ID`
LEFT JOIN `Category` ON `Category`.`ID` = `".$table."_Categories`.`CategoryID`",
$limit);
foreach($stream_items as $stream_item) {
$IsTweet = false;
// if is Tweet
if($stream_item->ClassName=="ExternalBlogEntry") {
$IsTweet = true;
$text = $stream_item->Title;
$text = $this->parseTweet($text);
$stream_item->Title = $text;
}
$stream_item->IsTweet = $IsTweet;
}
return $stream_items;
The Title is a property within the $stream_items object.
Thanks,
Garrett