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.

Template Questions

SOLVED - create a template page that does not extend any other


Reply

3 Posts   352 Views

Avatar
wake2010

10 January 2012 at 1:25am Community Member, 9 Posts

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
=]

Avatar
IOTI

10 January 2012 at 2:12am (Last edited: 10 January 2012 2:16am), Community Member, 189 Posts

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

}

Avatar
wake2010

10 January 2012 at 2:52am Community Member, 9 Posts

thanks worked!