Can you insert raw php code into the content section of a page in the admin part of the CMS? Or is there a way to insert php code into a page?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
No you cannot insert PHP in the text view. Though you can to a token in the text view for example you can you do $MyToken in the text editor then in your Page.php - Page_Controller class have a method
function Content() {
return str_replace('$MyToken', $this->CustomPHPCode(), $this->Content);
}
function CustomPHPCode() {
return "Hi!";
}
Then that will insert the CustomPHPCode() ("Hi!") in where every you have $MyToken in the template.
http://doc.silverstripe.com/doku.php?id=recipes:customising-content-in-your-templates