Hey, I was hoping that someone could help with this. I have created a new form field in my db called Sidebar. In sidebar I can put in keywords. E.g. news blogroll etc
The idea is that when the template is loaded, I will read what has been entered and output these various sidebar elements.
I have two questions.
I am aware I need to make a function called SideBar. Then I can use $SideBar in the template. Where does this function go? Secondly how do I gather and read this sidebar field that was inputted?
This is what I have so far.
<?php
class TwoColumnPage extends Page {
static $db = array(
'Sidebar' => 'Text'
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('Sidebar'), 'Content');
return $fields;
}
}
class TwoColumnPage_Controller extends Page_Controller {
}
?>
The second question is the best way to output these sidebar elements. I was going to put each Sidebar Element into the LayOut folder in my template.
e.g. sidebar_news, sidebar_blogroll
If I did this, is there a way to call these from a function in the file above? Do I need to return $SideBar_News, $SideBar_Blogroll or is this not possible.
Any advice given on both of these points is very much greatly appreciated.