Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Page Specific Templates

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

Page: 1
Go to End
Author Topic: 971 Views
  • lenwood
    Community Member
    18 Posts

    Page Specific Templates Link to this post

    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.


  • Willr
    Forum Moderator
    5508 Posts

    Re: Page Specific Templates Link to this post

    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.

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.