This should help if i understand correctly, what im doing is adding two textfields and two image uploading fields into the CMS (this code applies to my Left and Right Sidebars), my sidebars are just includes from SidebarLeft.ss and SidebarRight.ss, when these fields have content added via the CMS i want that content to be different across the pages.
firstly extend your pages relevent .php code in "mysite/code": (i extended my existing Page.ss so the file i added the code to is Page.php, this takes it across every page on my site, if you dont want that then you could use something like this http://www.silverstripe.org/template-questions/show/15692 or set up a page template just to use for the pages that you want to include the blocks)
<?php
class Page extends SiteTree {
static $db = array(
'HtagSbLone' => 'Text', // left sidebar.
'HtagSbLtwo' => 'Text',
'HtagSbRone' => 'Text', // right sidebar.
'HtagSbRtwo' => 'Text',
);
static $has_one = array(
"ImageSbLftone" => "Image", // left sidebar
"ImageSbLfttwo" => "Image",
"ImageSbRgtone" => "Image", //right sidebar
"ImageSbRgttwo" => "Image",
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.SidebarLeft", new TextField( "HtagSbLone", 'Header Tag One'));
$fields->addFieldToTab("Root.Content.SidebarLeft", new ImageField("ImageSbLftone", "Image One"));
$fields->addFieldToTab("Root.Content.SidebarLeft", new TextField( "HtagSbLtwo", 'Header Tag Two'));
$fields->addFieldToTab("Root.Content.SidebarLeft", new ImageField("ImageSbLfttwo", "Image Two"));
$fields->addFieldToTab("Root.Content.SidebarRight", new TextField( "HtagSbRone", 'Header Tag One'));
$fields->addFieldToTab("Root.Content.SidebarRight", new ImageField("ImageSbRgtone", "Image One"));
$fields->addFieldToTab("Root.Content.SidebarRight", new TextField( "HtagSbRtwo", 'Header Tag Two'));
$fields->addFieldToTab("Root.Content.SidebarRight", new ImageField("ImageSbRgttwo", "Image Two"));
return $fields;
}
}
?>
note this in the last block of code "Root.Content.SidebarLeft" this instructs that a new tab be created in the CMS called Sidebar Left this tab will then contain 2 text fields and two image uploading fields, Root.Content.SidebarRight is the same instruction but this creates my Right Sidebar tab,
all left to do then is just echo the variable out in its relevant place on its relevent page,
im new to this myself but if anybody can suggest another way then im all ears..