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.

Archive /

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

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

Is it better to change just CSS files or should I have 3 main Page Types?


Go to End


2 Posts   2134 Views

Avatar
pouderStream

Community Member, 33 Posts

20 February 2007 at 10:57am

Edited: 20/02/2007 11:03am

Hey guys.
On the site (www.fideam.com), I have three main sections (Company,Sience and Finance) witch differ solely in one css file.
I'm wondering what is better:
a)To have 3 main page types or
b)to have 1 main page type (aka Page.ss) and then define 3 childes in Layout folder (one for every section)?And how would I achieve this?With some custom function maybe?

And if is there a way to not showing a PageType in CMS backend?

Tnx ;)

Avatar
Sam

Administrator, 690 Posts

20 February 2007 at 12:19pm

If it really is just one CSS file, then doing something like this in the template would work. You'd need CSS files named the same as the URLs of the top-level pages

For example, if you're page is /company/, then you'd need to create company.css

<% control Level(1) %>
<link rel="stylesheet" href="mysite/css/{$URLSegment}.css" />
<% end_control %>

Hiding a page-type in the back-end can be defined by creating a canCreate() method on the appropriate class.

To disable the built-in classes, do it this way: since all the built-in types are sub-classes of Page, you could define this method on class Page: this would mean you could only create pages of type Page.

function canCreate() {
return $this->class == "Page";
}