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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

Stylesheet/Menu items missing from page type


Go to End


3 Posts   1274 Views

Avatar
Hamish

Community Member, 712 Posts

19 May 2008 at 11:57am

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

Community Member, 712 Posts

19 May 2008 at 12:02pm

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

Community Member, 712 Posts

19 May 2008 at 1:41pm

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?