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.

Archive

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

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

Stylesheet/Menu items missing from page type


Reply

3 Posts   993 Views

Avatar
Hamish

19 May 2008 at 11:57am Community Member, 712 Posts

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!

Avatar
Hamish

19 May 2008 at 12:02pm Community Member, 712 Posts

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

Avatar
Hamish

19 May 2008 at 1:41pm Community Member, 712 Posts

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?