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

Page Specific Templates


2 Posts   976 Views


27 March 2010 at 10:16am Community Member, 18 Posts

Hi All,
I know that this is probably simple to accomplish but the answer is eluding me. How do I create a template that will only be applied to a couple of pages? I'd like for the site to have a couple pages with nothing but an image, no header, no logo, no navigation menu, just an image. I'm having a hard time figuring out how to accomplish this.



27 March 2010 at 3:38pm Forum Moderator, 5511 Posts

Well the easiest way is to just make new page types. So the pages which have different layouts would be a different page type to the others. Tutorial 2 covers making new page types.

If you don't want to make separate page types for the layouts you could do something like have a dropdown field on the page in the cms where the user can choose the page template.


class Page extends SiteTree {

static $db = array(
'Template' => "Enum('One, Two, Three', 'One')"

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Template', new DropdownField('Template', 'Template', $this->dbObject('Template')->enumValues());

return $fields;

That will put the template option in the cms. then in the function init() in that same file you can use $this->renderWith($this->Template) to implement a custom template. Making separate page types is easier.