[EDIT]
There is now a tutorial on creating a sidebar on SSbits.com
http://www.ssbits.com/create-a-static-sidebar-editable-from-the-cms/
[/EDIT]
Hi Martin, welcome to silverstripe :)
Here is what you need to do:
First create a class for your Links. We need to make the links objects so that you can then add as many as you want to your page.
So your code for the Links class might look something like this:
<?php
class Link extends DataObject {
static $db = array(
'Link' => 'Varchar(255)',
'LinkText' => 'Varchar(255)',
);
static $has_one = array(
'LinksPage' => 'LinksPage',
);
function getCMSFields_forPopup() {
return new FieldSet(
new TextField('Link'),
new TextField('LinkText')
);
}
}
?>
Notice the '$has_one' variable. This is to tell SS that the each link will be connected to a LinksPage.
Next we create our Links page type in which you will be able to control your links from:
class LinksPage extends Page {
static $db = array(
);
static $has_many = array(
'Links' => 'Link',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$LinkField = new HasManyComplexTableField(
$this,
'Links',
'Link',
array(
'Link' => 'Link',
'LinkText' => 'LinkText',
),
'getCMSFields_forPopup',
);
$LinkField->relationAutoSetting = true;
$LinkField->setAddTitle( 'A Link' );
$fields->addFieldToTab( 'Root.Content.Links', $LinkField );
//you wont need any content on your sidebar so lets remove it's field
$fields->removeFieldFromTab("Root.Content.Main","Content");
return $fields;
}
}
class LinksPage_Controller extends Page_Controller{
}
?>
Then in your Page_Controller you can create a function that will get your links and return them to the template:
function GetLinks(){
$LinksPage = DataObject::get_one("LinksPage");
return ($LinksPage) ? DataObject::get("Link", "LinksPageID = {$LinksPage->ID}") : false;
}
Finally in your SideBar.ss include you can now call <% Control GetLinks %> which will return all your links.
Hope that helps, any questions just ask :)
Aram