Jump to:

3392 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » SOLVED - create a template page that does not extend any other

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

Page: 1
Go to End
Author Topic: 300 Views
  • wake2010
    Avatar
    Community Member
    9 Posts

    SOLVED - create a template page that does not extend any other Link to this post

    Hey, i am trying to make the main hope page tutorial not extend page as i am creating its own CSS and i have hit a snag

    first, how do you make a the MainHomePage not be an extention of page.
    seccond, how do you add a unique CSS to one page?
    thanks for any help
    =]

  • IOTI
    Avatar
    Community Member
    187 Posts

    Re: SOLVED - create a template page that does not extend any other Link to this post

    instead of extending Page extend SiteTree

    class MainHomePage extends SiteTree {

    }

    class MainHomePage_Controller extends ContentController {

    }

    that should work. If the only reason you want to do this is to have custom CSS on your homepage, you can still extend Page and have different CSS for MainHomePage.

    instead of putting your MainHomePage.ss template in /templates/layout, put MainHomePage.ss in your /templates folder and then use <% require themedCSS() %> to include the css files you want.

    Another way to include CSS is through the use of Requirements in your init() function

    class MainHomePage_Controller extends Page_Controller {

    public function init() {
          parent::init();

          Requirements::CSS('themes/'. SSViewer::current_theme() .'/css/file.css');
       }

    }

  • wake2010
    Avatar
    Community Member
    9 Posts
    300 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.