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.

Template Questions /

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

removing footer etc from a sub-template


Go to End


3 Posts   2536 Views

Avatar
Scorpiankh

Community Member, 63 Posts

14 March 2010 at 2:49pm

For a website I'm working on, the homepage needs to have a completely different layout from the rest of the site, also it has a different header and menu, and no foooter.

I tried makin the HomePage a template extending from sitetree first but it was still including the header menu and footer from the Page page type.

Also tried making it a subtemplate of Page and used $URLSegemnt in the <body> tag to create a page id so I could try and remove or make the items display differently in the css file, which half worked, checking the source code once the page had been generated it was showing the homepage with <body id="home"> but none of my #home css styles were being applied to the page.

So is there a way to either make the HomePage page type not inherit from the Page page type, or to remove the header menu and footer in the template?

The only other way i can think of to do it at the mo is to leave the Page page type blank inside the body tags and include the header footer and menu individually on each sub-template except the HomePage.

Avatar
Willr

Forum Moderator, 5523 Posts

14 March 2010 at 4:11pm

You are probably using a HomePage sub template (eg a HomePage.ss inside yourtheme/templates/Layout/.) this means that the template parser will use Page.ss in yourtheme/templates which has the header / footer. What you want to do is define HomePage.ss as a root template (in yourtheme/templates/ rather than a subtemplate. Then Page.ss will not be used at all.

Other option is to wrap your header / footer in Page.ss with <% if URLSegment != home %>...

Avatar
Scorpiankh

Community Member, 63 Posts

15 March 2010 at 11:54am

Ok I tried again making the HomePage a template in /templates/ folder and it worked this time, not sure what I did wrong before, i don't think I had it in the Layout folder before ... but anyways, working now so all good :D thanks