1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Tags with Apostrophes Break the Link
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 618 Views |
-
Tags with Apostrophes Break the Link

19 January 2012 at 10:31am
Hi,
I have a site where I'd like one of the tags to have an apostrophe (ie, What's Cooking). For any normal tag (that has no apostrophe) clicking on the tag will show you all of the posts with that tag. But my tag with the apostrophe won't pull up any results.
Any suggestions for correcting this would be great.
Thanks!
June
-
Re: Tags with Apostrophes Break the Link

20 January 2012 at 4:03pm
Sounds like a bug - it should encode the tag text to format it using HTML entities (i.e ' for '). If you can, dig down into the template that outputs the tags and find the variable, rather than $Something should be $Something.XML to ensure it's escaped.
-
Re: Tags with Apostrophes Break the Link

7 February 2012 at 12:37pm Last edited: 7 February 2012 1:09pm
It is indeed a bug. I too had this problem with needing to use an apostrophe in a tag. Since single quotes ( ' ) are allowed in URL's, trying to format with htmlentities or urlencode in the controller (or the template $Link.XML method) had no effect on the actual URL being generated by the link.
Instead, I found that the tag code was being converted to it's HTML entity (') prior to the SQL query being run:
In BlogTree_Controller::SelectedTag() (Convert::raw2xml() - BlogTree.php line #300).My simple solution was to edit BlogTree.php line #300 to remove the raw2xml conversion as below:
return ($this->request->latestParam('Action') == 'tag') ? $this->request->latestParam('ID') : '';
It's perhaps a temporary solution, but it certainly worked for me.
UPDATED
On second thought, it's probably best to keep the raw2xml conversion in the SelectedTag() function, as this function is also used for template output. Instead, edit BlogTree.php line #160 to revert the xml conversion back to raw for the purpose of escaping for the query:
$SQL_tag = Convert::raw2sql(Convert::xml2raw($tag));
This is probably the better solution.
| 618 Views | ||
|
Page:
1
|
Go to Top |



