Jump to:

1374 Posts in 487 Topics by 520 members

Themes

SilverStripe Forums » Themes » Doesn't show templates\Page.ss - only templates\Layout\Section.ss

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 1911 Views
  • Hammy
    Avatar
    Community Member
    49 Posts

    Doesn't show templates\Page.ss - only templates\Layout\Section.ss Link to this post

    I'm running silverstripe 2.3.0-rc3 (but had the same issue in 2.3.0-rc2) and after creating some templates i'm only able to get a single template to show at a time.

    I have the following template files

    \themes\awesome\templates\Page.ss
    \themes\awesome\templates\Layout\Page.ss
    \themes\awesome\templates\Layout\Section.ss
    \themes\awesome\templates\Layout\Detail.ss

    So obviously \themes\awesome\templates\Page.ss is the main template and the templates under \themes\awesome\templates\Layout\ should be injected in the space where $Layout is in the main template \themes\awesome\templates\Page.ss.

    However, when I try to access a page that uses either \themes\awesome\templates\Layout\Section.ss or \themes\awesome\templates\Layout\Detail.ss, only the HTML markup from that template is displayed and the surrounding HTML markup from \themes\awesome\templates\Page.ss is missing.

    Here is an example of the 2 templates:

    \themes\awesome\templates\Page.ss (still a work in progress ;)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
       <head>
          <% base_tag %>
          $MetaTags
          <link rel="stylesheet" type="text/css" href="/awesome/css/screen.css" />
       </head>
       <body>
          <div id="page">
             <div id="header">
                <a title="Awesome" class="logo" href="/"><img src="" alt="Awesome"></a>
                <ul>
                   <li><a href="#">Section</a></li>
                </ul>
             </div>
             <div id="content">
                $Layout
                $Form
                <div id="sidebar">
                   <h2>Side Bar</h2>
                </div>
             </div>
             <div id="footer">
                <p>Footer</p>
             </div>
          </div>
       </body>
    </html>

    \themes\awesome\templates\Layout\Section.ss (which should be injected into $Layout in the above template)

    <div id="main">
       <h1>$Title</h1>
       $Tagline
    </div>

    Instead of getting the two combined templates, I only get the later.

    What am I doing wrong? Have I missed something? Has anyone else had this issue?

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Doesn't show templates\Page.ss - only templates\Layout\Section.ss Link to this post

    Weird

    How do you get it to use them? I suppose you have a pagetype Detail and one Section then (Detail.php and Section.php)? Otherwise it won't work unless you do it manually with renderWith(array("Section", "Page"));

    Perhaps if you pastie your php code I can tell you more.

  • Hammy
    Avatar
    Community Member
    49 Posts

    Re: Doesn't show templates\Page.ss - only templates\Layout\Section.ss Link to this post

    Totally weird

    Not sure if this helps, but i'm running WAMP as the development server...

    Below is the php code for both Page and Section (both of which appear fine in the SS Admin)

    Page.php

    <?php

    class Page extends SiteTree {
       
       public static $db = array(
       );
       
       public static $has_one = array(
       );
       
    }

    class Page_Controller extends ContentController {

    }

    ?>

    Section.php

    <?php

    class Section extends Page {
       
       public static $db = array(
          'Tagline' => 'Text'
       );
       
       public static $has_many = array(
          'Detail' => 'Detail',
          'Sizes' => 'FilterSizeType'
       );
       
       static $allowed_children = 'none';
       
       static $defaults = array(
          'ShowInSearch' => false,
          'ShowInMenus' => true
       );
       
       function getCMSFields() {
          
          // Size List
          $sizesList = new HasManyComplexTableField(
             $this,
             'Sizes',
             'FilterSizeType',
             array(
                'Sexes' => 'Guys/Girls',
                'SizeName' => 'Size Name',
                'SizeAbbreviation' => 'Size Abbreviation',
                'Sequence' => 'Sequence'
             ),
             'getCMSFields_forPopup'
          );
          $sizesList->setParentClass('Section');
          $sizesList->setShowPagination(false);
          $sizesList->setPageSize(1000);
          
          $fields = parent::getCMSFields();
          
          $fields->addFieldToTab('Root.Content.Main', new TextareaField('Tagline'), 'Content');
          $fields->addFieldToTab( 'Root.Content.Sizes', $sizesList );
          
          $fields->removeFieldFromTab('Root.Content.Main', "MenuTitle");
          $fields->removeFieldFromTab('Root.Content.Main', "Content");
          
          return $fields;
       }
       
    }

    class Section_Controller extends ContentController {
       
    }

    ?>


    I am using SVN and am starting to going backwards in the versions to see where this issue begins in this project... Will add any info if I find anything else ;)

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Doesn't show templates\Page.ss - only templates\Layout\Section.ss Link to this post

    class Section_Controller extends ContentController {

    That should be

    class Section_Controller extends Page_Controller {

  • Hammy
    Avatar
    Community Member
    49 Posts

    Re: Doesn't show templates\Page.ss - only templates\Layout\Section.ss Link to this post

    Thanks Will (and dio5) for your help - that fixed the problem.

    1911 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.