Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Can you?


Go to End


2 Posts   1563 Views

Avatar
ladrao2007

Community Member, 16 Posts

18 July 2008 at 7:24am

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?

Avatar
Willr

Forum Moderator, 5523 Posts

18 July 2008 at 2:00pm

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