21309 Posts in 5738 Topics by 2603 members
General Questions
SilverStripe Forums » General Questions » Overloading Index() on Page_Controller breaks Shortcode Parsing
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 667 Views |
-
Overloading Index() on Page_Controller breaks Shortcode Parsing

10 February 2011 at 2:19pm
On a site that used to be 2.3.7 I upgraded it to 2.4.4 and found that now when I use the links sidebar in the CMS the links are inserted as shortcode. However since I have overloaded Index() in my controller and
return array(
'Content' => $this->Content,
'Form' => $this->Form
);The shortcode does not get parsed and so the links in Content don't work. On this site I changed my Index() function to Content() and just return $this->Content after modifying it in the function.
Can we no longer overload Index() in 2.4.4?
-
Re: Overloading Index() on Page_Controller breaks Shortcode Parsing

10 February 2011 at 8:34pm
You can still overload it, the issue you're facing is that links aren't being rewritten as the parser jumps in at the template level and it only parses HTMLText fields which in your array it is not, your returning just a string.
Solution is to return a new database object
return array(
'Content' => DBField::create('HTMLText', $this->Content);
);Though if you aren't changing $this->Content in index you shouldn't even need that line as it will automatically fallback to $this->Content on the object.
| 667 Views | ||
|
Page:
1
|
Go to Top |


