{
"title" : "About",
"description" : "Holds the content and metadata for our About page"
}
"content" : {
"list" : {
"Hello",
"World",
"This",
"Page",
"Rocks"
}
}
private function _setAboutList($list_data)
{
$this->_view->about_list = null;
foreach ($list_data as $list_item)
{
$this->_view->about_list .= $this->_view->buildAboutList($list_item);
}
}
public function buildAboutList($list_item)
{
return '<li>' . $list_item . '</li>';
}
protected function _pageBuilder($data, $cache_buster = null)
{
$this
->_setViewProperty('title_page', $data['template']['head']['title_page'][strtolower(__CLASS__)]['text'])
->_setViewProperty('example_content', $data['example']['content']);
return parent::_pageBuilder($data, $cache_buster);
}
->_setAboutList($data['about']['content']['list'])
<ul><?php echo $this->about_list; ?></ul>
"about" : {
"text" : "About"
"submenu" : ""
}
"about" : {
"text" : "About"
"is_anchor" : "1"
"is_internal" : "1"
"path" : ""
"target" : "_self"
"title" : ""
"id" : ""
"class" : ""
}
Basic Development Example
(INSTRUCTIONS LAST UPDATED FOR V3.0)
Ok, let's get to some nitty-gritty. You've got A Bright CMS installed and ready to go and you want to add something to your website. Let's say you'd like to add an about page with a list.
Navigate to application/controllers/example.php and find/replace all instances of "Example" with "About". Then rename "example.php" to "about.php". Optionally, you could create a new about.php file and copy and paste the contents of example.php and then perform the find/replace action. Do the same with "exampleView.php" in application/views and "exampleModel" in application/models.
Then, create a new file named about.json and add it to your dev/json directory. In this file, create a title and a description like so:
Underneath description, we can add a content section, and then our list like so:
Next we need to create a method in our About controller that will allow us to feed our data into the view. Such a method might look like the following:
Now we need to create the "buildAboutList" method in our view. Navigate to the "aboutView.php" we created earlier and enter the following in our class:
Let's go back to our About controller. We want to make sure that the private method we added in our controller is called when the page is loaded. All page controllers should have a "_pageBuilder" that calls all the methods necessary to render our view. If we kept the code from the example.php file, it should look something like this:
Add the following line of code after "$this" and above the first method call:
Our data is being passed to the "_pageBuilder" from the "index" already, so all we need to do is point to the part of the array that contains our list data.
The last thing we must do, is add the "$this->_view->about_list" property to a view page. Go to application/views and change the "example" to "about", or copy the contents to a new "about" folder. Then load the index.php file and add the following line inside the container div:
If we wish to add an "About" page to the interface with the proper metadata, we must add it to the template.json and header.json files. In the template.json file, look for the "title_page" section under the "head" section. Either change the "example" reference to "about" or add it like so:
Finally, in header.json, under the "header_nav" section, change the "example" section or add the following:
Congratulations! Now when you refresh the website, you should see an "About" page that will display your list when you navigate to it. We have now cleanly separated our content, our view pages, our view methods, and our controller methods. Changing our content, how it is displayed, or using these techniques as the basis of something more complex has been made clean and maintainable.