Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Stylesheet/Menu items missing from page type

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 973 Views
  • Hamish
    Avatar
    Community Member
    712 Posts

    Stylesheet/Menu items missing from page type Link to this post

    Hi, I posted this on the google group too.

    I'm building my first Silverstripe powered website for a corporate site. I am really enjoying the ease and speed of development, but I've hit a snag: for one page subclass the generated html is missing the stylesheets in the head and menu elements in 'control Menu' template tags.

    Page is called 'DocumentsGroup.php':

    class DocumentsGroup extends Page {
       static $db = array();
       
       static $has_many = array(
          'Documents' => 'Document'
       );
       
       function getCMSFields() {
          $fields = parent::getCMSFields();
          
          $tablefield = new HasManyComplexTableField(
             $this,
             'Documents',
             'Document',
             array(
                'DocName' => 'Document Title',
                'DocPublishDate' => 'Release Date'
             ),
             'getCMSFields_forPopup'
          );
          
          $tablefield->setAddTitle( 'A Document' );
          
          $fields->addFieldToTab( 'Root.Documents', $tablefield );
          
          return $fields;
       }
    }

    class DocumentsGroup_controller extends Page_Controller {
       function init() {
          parent::init();
       }
    }

    Document is a DataObject - Document.php looks like:

    class Document extends DataObject {

       static $db = array(
          'DocName' => 'Text',
          'DocDescription' => 'Text',
          'DocPublishDate' => 'Date',
       );
       
       static $has_one = array(
          'MyDocumentGroup' => 'DocumentsGroup',
          'DocFile' => 'File'      
       );
       
       function getCMSFields_forPopup() {
       
          $fields = new FieldSet();
          $fields->push( new TextField( 'DocName', 'Document Title' ) );
          $fields->push( new TextareaField( 'DocDescription', 'Description') );
          $fields->push( new CalendarDateField( 'DocPublishDate', 'Release Date') );
          $fields->push( new FileIFrameField( 'DocFile', 'Upload Document' ) );
          
          return $fields;
       
       }
    }

    In my Page.php, I'm using the Requirements::themedCSS calls to include stylesheets. For normal 'pages' and a couple of other page subclasses I have created, this is working fine. For some reason, this particular page type is ditching the CSS and menu items.

    Ie, this:

    <ul>
       <% control Menu(1) %>
       <li class="$LinkingMode"><a href="$Link" title="Go to $Title.XML">$MenuTitle</a></li>
       <% end_control %>
    </ul>

    Just generates as

    <ul></ul>

    regardless of where in the sitetree the page is, or how many children/siblings/parents the node has.

    Any clues? Thanks in advance!

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Stylesheet/Menu items missing from page type Link to this post

    Just a note, I tried putting this in the DocumentsGroup_Controller class

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

    as an attempt to fix but it's not longer in the source. It didn't help.

    I've also rebuilt/flushed/cleared cache etc with no change.

    Thanks

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Stylesheet/Menu items missing from page type Link to this post

    OMG, just figured it out myself... lower cap c in "DocumentsGroup_Controller". Didn't throw any errors tho - shouldn't it check that the class exists?

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