Hi ampedup.
Yes, I want a unique sidebar but not only one but for different sections different sidebars (content).
I followed an example (German SS Forum http://www.silverstripes.de/mvc-coding/show/130?showPost=1434) but can not complete it.
What I have:
There is a new SiteTree select field above my 'content' in the back-end where I can select a page. But when I click save my selection gets lost, it seems SS can't save it in the DB, although there is no error.
The Code: (mysite/code/Page.php)
class Page extends SiteTree {
static $db = array(
);
static $has_one = array(
'Hintergrundbild' => 'Image',
'Sidebar' => 'Page'
);
// Verbindung Hintergrundbild zur Bild-Datenbank
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Hintergrundbild", new ImageField('Hintergrundbild'));
$fields->addFieldToTab('Root.Content.Main', new TreeDropdownField("Sidebar", "Sidebar anzeigen", "SiteTree"), 'Content');
return $fields;
}
}
Code 2: (mysite/code/Sidebar.php)
<?php
class Sidebar extends Page {
static $db = array();
static $has_one = array();
}
class Sidebar_Controller extends Page_Controller {
}
?>
Code 3: (themes/n1/templates/Page.ss)
<p>Start Sidebar</p>
<% control Sidebar %>
<div id="contentright">
sidebar Content: $Content
</div>
<% end_control %>