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:

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

content from custom SS file not displayed in correct place

Go to End

4 Posts   864 Views


Community Member, 4 Posts

1 October 2010 at 2:59am

Edited: 01/10/2010 3:59am

Hey guys,
I followed the "Extending Silverstripe" Tutorial and created an additional page type - CustomPage.

I put the CustomPage.php file in the mysite/code folder with the following:

class CustomPage extends Page {
   static $db = array(
   static $has_one = array(
class CustomPage_Controller extends Page_Controller {
function showstuff(){
echo "hi!";

I put a simple echo statement in my new function "showstuff()" to test with.

Then I added to the template/layout folder, and it contains:


But the problem is, "Hi!" is displayed ABOVE anything else on the page (header, content divs, etc.).

If I put some text inside the file, it displays in the correct content portion of the page. So for some reason when it calls the function it seems to lose where it is on the page.


Forum Moderator, 1899 Posts

1 October 2010 at 11:24pm


What is the full path of the template you are using and which theme are you using... Maybe if the site is small it might be worth uploading your mysite and theme folder as it could be to do with the location of the templates. Another thing to try is a complete refresh (i.e. instead of just a dev build) create a 'silverstripe-cache' folder in your webroot to ensure it uses that as the cache and then you can delete the contents of the cache to enforce a complete refresh.



Forum Moderator, 5523 Posts

2 October 2010 at 10:45pm

You shouldn't echo anything. Instead use return "hi"; if you use echo it echos immediately hence before SilverStripe complies the template.


Community Member, 4 Posts

5 October 2010 at 7:42am

Willr, Thanks! that worked. I may post again once I put my actual PHP code in, if I run into any problems