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'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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

PHP code


Go to End


5 Posts   1222 Views

Avatar
Berk

Community Member, 2 Posts

29 April 2015 at 10:05pm

Edited: 30/04/2015 1:29am

Hello, how add PHP code on the page?

Avatar
codemonkey88

Community Member, 24 Posts

30 April 2015 at 8:58pm

PHP lives in the mysite folder, with files that have the same name as your ss file.

So
MyPage.php

class Mypage_controller extends Page_controller
{
function Hello()
{
echo "Hello, how are you?";
}
}

MyPage.ss
$Hello // outputs "Hello, how are you?"

Avatar
Berk

Community Member, 2 Posts

30 April 2015 at 9:30pm

Maybe there is a addon for tinymce?

Avatar
swaiba

Forum Moderator, 1899 Posts

1 May 2015 at 4:33am

No there is no "add on for tinymce" as this is designed for editing HTML content.
codemonkey88 has given an excellent brief example and I would encourage you to consider that more and maybe complete all the tutorials and then return and you should then understand more.

Of course I could have misunderstood as you posts are quite vague as to what you are trying to do...

Avatar
camfindlay

Forum Moderator, 267 Posts

1 May 2015 at 9:26am

Hi Berk,

Are you asking how to display syntax highlighted code as content on a page perhaps?

You can use the <code> tag in your html content and simply apply some css style or perhaps a javascript syntax highlighting plugin over the page (for example https://highlightjs.org/).

Hope that helps.