Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

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

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

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

Page: 1
Go to End
Author Topic: 1412 Views
  • pouderStream
    Avatar
    Community Member
    33 Posts

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

    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 ;)

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Is it better to change just CSS files or should I have 3 main Page Types? Link to this post

    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";
    }

    1412 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.