Skip to content
Browse files

renamed and organized skin templates. added fallback techniquewhen vi…

…ews are not found.
  • Loading branch information...
1 parent 3b7c35f commit b7bd88a778668438264d5ab6dea846602909b757 @jordan-wilson committed May 18, 2012
Showing with 652 additions and 157 deletions.
  1. +77 −1 README
  2. +20 −21 app/front/controllers/blocks.controller.php
  3. +75 −24 app/front/controllers/blogs.controller.php
  4. +50 −57 app/front/controllers/forms.controller.php
  5. +0 −3 app/front/controllers/pages.controller.php
  6. +23 −3 app/front/core/controller.php
  7. +42 −0 app/front/core/functions.php
  8. +4 −5 app/front/core/registry.php
  9. +6 −0 app/front/models/blocks.model.php
  10. +4 −4 app/front/models/blogs.model.php
  11. +8 −6 app/front/models/forms.model.php
  12. +40 −25 app/front/models/layouts.model.php
  13. +3 −1 index.php
  14. +1 −3 skins/front/default/{layout.blogs.template.php → blogs.default.layout.php}
  15. +45 −0 skins/front/default/blogs.post.layout.php
  16. +17 −0 skins/front/default/css/blogs.css
  17. +19 −1 skins/front/default/css/forms.css
  18. 0 skins/front/default/{footer.template.php → footer.layout.php}
  19. 0 skins/front/default/{header.template.php → header.layout.php}
  20. +35 −0 skins/front/default/pages.default.layout.php
  21. +15 −3 skins/front/default/{layout.main.template.php → pages.home.layout.php}
  22. +61 −0 skins/front/default/pages.skin1.layout.php
  23. 0 skins/front/default/{blocks.blue.template.php → templates/blocks.blue.block.php}
  24. 0 skins/front/default/{blocks.default.template.php → templates/blocks.default.block.php}
  25. 0 skins/front/default/{blocks.green.template.php → templates/blocks.green.block.php}
  26. 0 skins/front/default/{blogs.blog.block.template.php → templates/blogs/bak/blog.block.template.php}
  27. +12 −0 skins/front/default/templates/blogs/bak/blog.full.template.php
  28. 0 ...default/{blogs.categories.block.template.php → templates/blogs/bak/categories.block.template.php}
  29. 0 ...s/front/default/{blogs.recent.block.template.php → templates/blogs/bak/recent.block.template.php}
  30. +11 −0 skins/front/default/templates/blogs/bak/recent.block2.template.php
  31. 0 ...t/default/{blogs.subscribe.block.template.php → templates/blogs/bak/subscribe.block.template.php}
  32. +12 −0 skins/front/default/templates/blogs/blog.default.block.php
  33. +12 −0 skins/front/default/templates/blogs/blog.full.block.php
  34. +10 −0 skins/front/default/templates/blogs/categories.default.block.php
  35. 0 skins/front/default/{blogs.landing.template.php → templates/blogs/index.template.php}
  36. +11 −0 skins/front/default/templates/blogs/recent.default.block.php
  37. +11 −0 skins/front/default/templates/blogs/recent.green.block.php
  38. +5 −0 skins/front/default/templates/blogs/subscribe.default.block.php
  39. 0 skins/front/default/{blogs.view.template.php → templates/blogs/view.template.php}
  40. +23 −0 skins/front/default/templates/forms.default.block.php
  41. 0 skins/front/default/{ → templates}/pages.content.template.php
View
78 README
@@ -1 +1,77 @@
-CMS driven by MVC framework written in PHP
+CMS driven by MVC framework written in PHP
+
+
+
+
+LAYOUTS
+ Layouts are retreived from the "layouts.model.php". The values returned are used to find the layout file to use.
+ The string is created in the base "controller" class, by the public "parse_page_layout()" method.
+
+ Page layouts have two parameters:
+ 1) controller defaults to the named constant "DEFAULT_CONTROLLER"
+ 2) skin defaults to the string literal "default"
+
+ examples:
+ pages.default.layout.php, pages.home.layout.php
+ blogs.default.layout.php, blogs.post.layout.php
+
+
+
+
+TEMPLATES
+ Templates are hard coded into the actual controller so there is no real naming convention.
+
+ There are two types of templates:
+ 1) Content templates
+ overrides the pages default [content] block
+ loaded through the controller's public "index()" method
+ examples:
+ pages.content.template.php,
+ blogs.index.template.php, blogs.view.template.php
+
+ 2) Block tempates
+ block content added to the layout
+ loaded through the controller's public "get_block()" method
+ examples:
+ blocks.default.block.php, blocks.blue.block.php,
+ blogs.subscribe.default.block.php, blogs.recent.default.block.php, blogs.recent.green.block.php
+
+
+
+BLOCKS
+ Block data is retreived from the "layouts.model.php" within the cells array.
+ The data is retreived in the base "controller" class, by the public "parse_page_layout()" method.
+ It's used to find and load the appropriate controller that'll load and return the block template.
+
+ Blocks have two parameters:
+ 1) controller controller to load - the method "get_block()" is always called
+ 2) arguments a string to pass to "get_block()"
+
+ examples:
+ '[blocks:6]',
+ '[forms:2]',
+ '[blogs:subscribe]', '[blogs:recent]', '[blogs:recent.green]',
+
+ The first parameter in the file name is the controller to load. Everything else is a parameter that gets
+ passed to the controller's public "get_block()" method.
+
+ The block '[blogs:recent]' will load the "blogs" controller and call the "blogs->get_block()" method
+ which knows it needs to call the "blogs->_get_recent_block()" method. Then it'll load and return the
+ "blogs.recent.default.block.php" template file. The block '[blogs:recent.green]' will do the same
+ but load and return the "blogs.recent.green.block.php" template file.
+
+
+
+
+
+LOAD_VIEW()
+ The following is an example of how the "load_view()" will attempt to locate a template file.
+ load_view: 'blocks.default.block.php'
+ 1st attempt: '/skins/APP/SKIN/blocks.default.block.php'
+ 2nd attempt: '/skins/APP/SKIN/templates/blocks.default.block.php'
+ 3rd attempt: '/skins/APP/SKIN/templates/blocks/default.block.php'
+
+ Some modules have a lot of extra content and block templates so this just makes it easy to organize them
+ by allowing anyone to just grab them all and throw them into their own folder. Remember to remove the
+ module name from the beginning of the template file name if they are in their own folder (3rd attempt).
+
View
41 app/front/controllers/blocks.controller.php
@@ -3,31 +3,30 @@
class blocks extends controller
{
- public function get_block( $arg = '' )
+ public function get_block( $id = 0 )
{
- if (is_numeric($arg))
+ if ( ! is_numeric($id)) return '';
+
+ // get block info
+ $blocks_model = load_model('blocks');
+ $data = $blocks_model->get_block($id);
+
+ // if blog not found
+ if ( ! count($data)) return '';
+
+ // the default template
+ $default = 'blocks.default.block.php';
+
+ // if using custom template
+ if ($data['skin'] != '')
{
- // get block info
- $blocks_model = load_model('blocks');
- $data = $blocks_model->get_block($arg);
-
- if ( ! count($data)) return '';
-
- // the template to use for the block
- $template = 'blocks.default.template.php';
- if ($data['skin'] != '')
- {
- $skin = 'blocks.' . $data['skin'] . '.template.php';
- $path = SITE_ROOT . '/skins/' . APP . '/' . $this->registry->skin . '/' . $skin;
- if (file_exists($path))
- $template = $skin;
- }
-
- // load block
- return load_view($template, $data);
+ // load the custom template
+ $template = 'blocks.' . $data['skin'] . '.block.php';
+ return load_view($template, $data, $default);
}
- return '';
+ // load the default template
+ return load_view($default, $data);
}
}
View
99 app/front/controllers/blogs.controller.php
@@ -5,9 +5,6 @@ class blogs extends controller
public function index()
{
- // update main template
- $this->main_template = 'layout.blogs.template.php';
-
// update page content
$request = $this->registry->request_args;
if (count($request) == 1)
@@ -21,6 +18,13 @@ public function index()
$this->registry->page_content = $this->_view($request[1]);
}
else {
+ /*
+ Right now I'm just redirecting the user to the error page since
+ I can't figure out how to load the error page using the pages
+ controller in an efficient way. I'll probably need to stick it
+ where everyone can call it. Like the base 'controller' or
+ 'registry' classes.
+ */
header('Location: /error');
exit();
}
@@ -44,7 +48,7 @@ private function _index()
$this->_add_css();
// return html
- return load_view('blogs.landing.template.php', $data);
+ return load_view('blogs.index.template.php', $data);
}
@@ -94,95 +98,142 @@ public function get_block( $arg = '' )
if ( ! $this->registry->modules['blogs'])
return '';
+ // splite the argument into an array by '.'
+ $arg = explode('.', $arg);
+
// individual blog block
- if (is_numeric($arg))
+ if (is_numeric($arg[0]))
{
return $this->_get_blog_block($arg);
}
// subscribe block
- elseif ($arg == 'subscribe.block')
+ elseif ($arg[0] == 'subscribe')
{
- return $this->_get_subscribe_block();
+ return $this->_get_subscribe_block($arg);
}
// recent blog post block
- elseif ($arg == 'recent.block')
+ elseif ($arg[0] == 'recent')
{
- return $this->_get_recent_block();
+ return $this->_get_recent_block($arg);
}
// blog categories block
- elseif ($arg == 'categories.block')
+ elseif ($arg[0] == 'categories')
{
- return $this->_get_categories_block();
+ return $this->_get_categories_block($arg);
}
return '';
}
// individual blog block
- private function _get_blog_block( $id = 0 )
+ private function _get_blog_block( $arg = array() )
{
// the url of the blogs page
$data['link'] = '/' . $this->registry->modules['blogs'] . '/';
// get blog info
$blogs_model = load_model('blogs');
- $data['blog'] = $blogs_model->get_blog($id);
+ $data['blog'] = $blogs_model->get_blog($arg[0]);
// if blog not found
if ( ! $data['blog']) return '';
// add css
$this->_add_css();
- // return html
- return load_view('blogs.blog.block.template.php', $data);
+ // the default template
+ $default = 'blogs.blog.default.block.php';
+
+ // if using custom template
+ if ($arg[1])
+ {
+ // load the custom template
+ $template = 'blogs.blog.' . $arg[1] . '.block.php';
+ return load_view($template, $data, $default);
+ }
+
+ // load the default template
+ return load_view($default, $data);
}
// subscribe block
- private function _get_subscribe_block()
+ private function _get_subscribe_block( $arg = array() )
{
// the url of the blogs page
$data['link'] = '/' . $this->registry->modules['blogs'] . '/';
// add css
$this->_add_css();
- // return html
- return load_view('blogs.subscribe.block.template.php', $data);
+ // the default template
+ $default = 'blogs.subscribe.default.block.php';
+
+ // if using custom template
+ if ($arg[1])
+ {
+ // load the custom template
+ $template = 'blogs.subscribe.' . $arg[1] . '.block.php';
+ return load_view($template, $data, $default);
+ }
+
+ // load the default template
+ return load_view($default, $data);
}
// categories block
- private function _get_categories_block()
+ private function _get_categories_block( $arg = array() )
{
// the url of the blogs page
$data['link'] = '/' . $this->registry->modules['blogs'] . '/';
// add css
$this->_add_css();
+
+ // the default template
+ $default = 'blogs.categories.default.block.php';
- // return html
- return load_view('blogs.categories.block.template.php', $data);
+ // if using custom template
+ if ($arg[1])
+ {
+ // load the custom template
+ $template = 'blogs.categories.' . $arg[1] . '.block.php';
+ return load_view($template, $data, $default);
+ }
+
+ // load the default template
+ return load_view($default, $data);
}
// recent blog post block
- private function _get_recent_block()
+ private function _get_recent_block( $arg = array() )
{
// the url of the blogs page
$data['link'] = '/' . $this->registry->modules['blogs'] . '/';
// add css
$this->_add_css();
- // return html
- return load_view('blogs.recent.block.template.php', $data);
+ // the default template
+ $default = 'blogs.recent.default.block.php';
+
+ // if using custom template
+ if ($arg[1])
+ {
+ // load the custom template
+ $template = 'blogs.recent.' . $arg[1] . '.block.php';
+ return load_view($template, $data, $default);
+ }
+
+ // load the default template
+ return load_view($default, $data);
}
}
View
107 app/front/controllers/forms.controller.php
@@ -8,8 +8,12 @@ class forms extends controller
public function get_block( $id = 0 )
{
+ if ( ! is_numeric($id)) return '';
+
// check if form is unique
- if (in_array($id, $this->forms)) return '<p>FORM ' . $id . ' IS ALREADY IN USE ON THIS PAGE. YOU CANNOT HAVE MULTIPLE INSTANCES OF A FORM ON A SINGLE PAGE AT ONE TIME.</p>';
+ if (in_array($id, $this->forms))
+ return '<div class="forms_block" style="padding:5px; color:#fff; background-color:#870217">Form ' . $id . ' is already in use on this page. Only one instance of a form is allowed on the page.</div>';
+
$this->forms[] = $id;
// get the page url
@@ -29,16 +33,16 @@ public function get_block( $id = 0 )
{
// return either the form with errors or thank you text
$this->submitted = true;
- return $this->build_form($id, $url, true);
+ return $this->_build_form($id, $url, true);
}
}
// return the form
- return $this->build_form($id, $url);
+ return $this->_build_form($id, $url);
}
- public function build_form( $id = 0, $url = '', $validate = false )
+ private function _build_form( $id = 0, $url = '', $validate = false )
{
// get form info
$forms_model = load_model('forms');
@@ -68,54 +72,28 @@ public function build_form( $id = 0, $url = '', $validate = false )
// add css
- $this->add_css();
+ $this->_add_css();
- // the forms classname
- switch($form['type'])
- {
- case 'horizontal':
- $class = 'class="form_horizontal"';
- break;
- default:
- $class = '';
- }
+ // build the data array
+ $data = array();
+ $data['type'] = $form['type'];
+ $data['fields'] = join('', $fields);
+ $data['content'] = $form['content'];
+ $data['submitted'] = $this->submitted;
// the anchor link
- $name = 'form' . $form['id'];
-
-
- $html = '';
-
- // return thank you text
- if ($this->submitted)
- {
- $html .= '<a name="' . $name . '"></a>';
- $html .= '<div class="form_submitted">';
- $html .= $form['content'];
- $html .= '</div>';
- }
+ $data['name'] = 'form' . $form['id'];
- // else, return the form
- else
- {
- // the post url
- $action = '/' . $url . '/' . $form['id'] . '/submit#' . $name;
-
- // build the form
- $html .= '<form ' . $class . ' id="' . $name . '" action="' . $action . '" method="post">';
- $html .= join('', $fields);
- $html .= '<div class="form_actions">';
- $html .= '<button type="submit" class="btn">Submit</button>';
- $html .= '</div>';
- $html .= '</form>';
- }
+ // the post url
+ $data['action'] = '/' . $url . '/' . $form['id'] . '/submit#' . $data['name'];
- return $html;
+ // load view
+ return load_view('forms.default.block.php', $data);
}
- private function add_css()
+ private function _add_css()
{
$css = '/skins/' . APP . '/' . $this->registry->skin . '/css/forms.css';
$this->registry->add_css_by_url($css);
@@ -127,23 +105,27 @@ public function get_field( $arr = array(), $validate = array() )
switch($arr['type'])
{
case 'text_input':
- return $this->get_text_input($arr, $validate);
+ return $this->_get_text_input($arr, $validate);
break;
case 'textarea':
- return $this->get_textarea($arr, $validate);
+ return $this->_get_textarea($arr, $validate);
break;
case 'select':
- return $this->get_select($arr, $validate);
+ return $this->_get_select($arr, $validate);
+ break;
+
+ case 'heading':
+ return $this->_get_heading($arr);
break;
}
return false;
}
// focus on first incomplete field
- private function add_input_focus( $id = '' )
+ private function _add_input_focus( $id = '' )
{
if ($this->submitted)
{
@@ -154,7 +136,7 @@ private function add_input_focus( $id = '' )
// label
- private function get_field_label( $id = 0, $arr = array() )
+ private function _get_field_label( $id = 0, $arr = array() )
{
$html = '';
@@ -171,7 +153,7 @@ private function get_field_label( $id = 0, $arr = array() )
// text input
- private function get_text_input( $arr = array(), $validate = false )
+ private function _get_text_input( $arr = array(), $validate = false )
{
$id = 'field_' . $arr['id'];
$value = load_core('input')->post($id);
@@ -184,14 +166,14 @@ private function get_text_input( $arr = array(), $validate = false )
if (empty($value))
{
$error = '<div class="form_error">Please fill in this required field.</div>';
- $this->add_input_focus($id);
+ $this->_add_input_focus($id);
$this->submitted = false;
}
}
}
$html .= '<div class="input_container">';
- $html .= $this->get_field_label($id, $arr);
+ $html .= $this->_get_field_label($id, $arr);
$html .= '<div class="form_field">';
$html .= '<input type="text" id="' . $id . '" name="' . $id . '" value="' . htmlentities($value) . '" />';
$html .= $error;
@@ -203,7 +185,7 @@ private function get_text_input( $arr = array(), $validate = false )
// textarea
- private function get_textarea( $arr = array(), $validate = false )
+ private function _get_textarea( $arr = array(), $validate = false )
{
$id = 'field_' . $arr['id'];
$value = load_core('input')->post($id);
@@ -216,14 +198,14 @@ private function get_textarea( $arr = array(), $validate = false )
if (empty($value))
{
$error = '<div class="form_error">Please fill in this required field.</div>';
- $this->add_input_focus($id);
+ $this->_add_input_focus($id);
$this->submitted = false;
}
}
}
$html .= '<div class="input_container">';
- $html .= $this->get_field_label($id, $arr);
+ $html .= $this->_get_field_label($id, $arr);
$html .= '<div class="form_field">';
$html .= '<textarea id="' . $id . '" name="' . $id . '">' . $value . '</textarea>';
$html .= $error;
@@ -235,7 +217,7 @@ private function get_textarea( $arr = array(), $validate = false )
// select
- private function get_select( $arr = array(), $validate = false )
+ private function _get_select( $arr = array(), $validate = false )
{
$id = 'field_' . $arr['id'];
$value = load_core('input')->post($id);
@@ -248,14 +230,14 @@ private function get_select( $arr = array(), $validate = false )
if (empty($value))
{
$error = '<div class="form_error">Please select an option.</div>';
- $this->add_input_focus($id);
+ $this->_add_input_focus($id);
$this->submitted = false;
}
}
}
$html .= '<div class="input_container">';
- $html .= $this->get_field_label($id, $arr);
+ $html .= $this->_get_field_label($id, $arr);
$html .= '<div class="form_field">';
$html .= '<select id="' . $id . '" name="' . $id . '">';
$html .= '<option value=""></option>';
@@ -272,5 +254,16 @@ private function get_select( $arr = array(), $validate = false )
}
+ // heading
+ private function _get_heading( $arr = array() )
+ {
+ $html .= '<div class="input_heading">';
+ $html .= $arr['label'];
+ $html .= '</div>';
+
+ return $html;
+ }
+
+
}
View
3 app/front/controllers/pages.controller.php
@@ -5,9 +5,6 @@ class pages extends controller
public function index()
{
- // update main template
- $this->main_template = 'layout.main.template.php';
-
// update page content
$this->registry->page_content = load_view('pages.content.template.php', $this->registry->page_data);
View
26 app/front/core/controller.php
@@ -15,7 +15,12 @@ public function __construct()
}
// set default main template
- $this->main_template = DEFAULT_MAIN_TEMPLATE;
+ $this->header_template = DEFAULT_HEADER_TEMPLATE;
+ $this->layout_template = DEFAULT_LAYOUT_TEMPLATE;
+ $this->footer_template = DEFAULT_FOOTER_TEMPLATE;
+
+ // used as a fallback if custom layout isn't found
+ $this->default_layout_template = '';
}
@@ -26,12 +31,20 @@ public function parse_page_layout()
if (count($layout))
{
+ // update layout template
+ $layout_controller = ($layout['controller'] == '') ? DEFAULT_CONTROLLER : $layout['controller'];
+ $layout_skin = ($layout['skin'] == '') ? 'default' : $layout['skin'];
+ $layout_template = $layout_controller . '.' . $layout_skin . '.layout.php';
+ $this->layout_template = $layout_template;
+ $this->default_layout_template = DEFAULT_LAYOUT_TEMPLATE;
+
+
// load block content into each cell of the layout
foreach($layout['cells'] as $i => $cell)
{
foreach($cell as $j => $block)
{
- $html = '';
+ $html = $block;
// if regular page content
if ($block == '[content]')
@@ -77,8 +90,15 @@ public function display()
}
else
{
+ // load header
+ echo load_view($this->header_template);
+
+ // load layout (with default fallback)
$data = array('layout' => $this->registry->page_layout);
- echo load_view($this->main_template, $data);
+ echo load_view($this->layout_template, $data, $this->default_layout_template);
+
+ // load footer
+ echo load_view($this->footer_template);
}
}
}
View
42 app/front/core/functions.php
@@ -23,3 +23,45 @@ function load_core($class_name)
}
}
+
+
+//
+// LOAD VIEW
+//
+if ( ! function_exists('load_view'))
+{
+ function load_view($view, $vars = array(), $default = '')
+ {
+ // get skin from registry
+ $registry = load_core('registry');
+ $skin = $registry->skin;
+
+ // skins directory
+ $path = SITE_ROOT . '/skins/' . APP . '/' . $skin . '/' . $view;
+ if (file_exists($path))
+ return _return_view($path, $vars);
+
+ // skins templates directory
+ $path = SITE_ROOT . '/skins/' . APP . '/' . $skin . '/templates/' . $view;
+ if (file_exists($path))
+ return _return_view($path, $vars);
+
+ // skins templates modules directory
+ $path = SITE_ROOT . '/skins/' . APP . '/' . $skin . '/templates/' . preg_replace('/\./', '/', $view, 1);
+ if (file_exists($path))
+ return _return_view($path, $vars);
+
+ // app templates
+ $path = SITE_ROOT . '/app/' . APP . '/templates/' . $view;
+ if (file_exists($path))
+ return _return_view($path, $vars);
+
+
+ // check for a default template to fallback on
+ if ($default != '')
+ return load_view($default, $vars);
+
+ return 'View not found: ' . $view;
+ }
+}
+
View
9 app/front/core/registry.php
@@ -12,15 +12,14 @@ class registry
public $meta_keywords;
public $meta_description;
- public $modules;
- public $page_data;
- public $page_layout;
- public $page_content;
+ public $modules; // array of all page urls with modules
+ public $page_data; // the default database info of the page
+ public $page_layout; // the default layout of the page
+ public $page_content; // the default content block for the page
public function __construct()
{
$this->skin = DEFAULT_SKIN;
- $this->main_template = DEFAULT_MAIN_TEMPLATE;
}
public function add_js($js)
View
6 app/front/models/blocks.model.php
@@ -44,6 +44,12 @@ public function get_block( $id = 0 )
$arr['title'] = 'Block 6';
$arr['content'] = '<p>Donec id elit non mi porta gravida at eget metus. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>';
break;
+
+ case 7:
+ $arr['skin'] = '';
+ $arr['title'] = 'Block 7';
+ $arr['content'] = '<p>Facebook Like</p><p>Twitter Retweet</p><p>Google Plus</p>';
+ break;
}
return $arr;
View
8 app/front/models/blogs.model.php
@@ -44,7 +44,7 @@ public function get_blog( $id = 0 )
'url' => 'blog1',
'date' => strtotime('January 2, 2012'),
'name' => 'Blog 1',
- 'content' => '<p>Ut fermentum massa justo sit amet risus. Vestibulum id ligula porta felis euismod semper. Donec id elit non mi porta gravida at eget metus.</p>',
+ 'content' => '<p>Ut fermentum massa justo sit amet risus. Vestibulum id ligula porta felis euismod semper. Donec id elit non mi porta gravida at eget metus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dictum quam sed eros vestibulum et auctor turpis mattis. Praesent viverra semper lectus, sed facilisis mauris tincidunt non.</p><p>Sed sed tortor eget neque facilisis imperdiet. Integer tortor urna, dignissim vitae tempor eget, egestas ut velit. Suspendisse varius elit nec eros imperdiet vel viverra est tristique. Quisque lacus augue, gravida et pretium sed, imperdiet quis ipsum. Integer a suscipit tortor. Nullam sit amet neque est.</p>',
'meta_title' => 'Blog :: Blog 1',
'meta_keywords' => '',
'meta_description' => '',
@@ -55,7 +55,7 @@ public function get_blog( $id = 0 )
'url' => 'blog2',
'date' => strtotime('January 14, 2012'),
'name' => 'Blog 2',
- 'content' => '<p>Donec id elit non mi porta gravida at eget metus. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>',
+ 'content' => '<p>Donec id elit non mi porta gravida at eget metus. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Sed pellentesque fermentum rutrum.</p><p>Donec nec dui hendrerit libero imperdiet malesuada vel et dui. Aenean ut est a massa mollis lacinia. Cras metus quam, tincidunt vitae convallis a, ullamcorper a lorem. Aenean ante ipsum, porta quis sodales nec, tristique ac nunc. Pellentesque id ligula quam, in commodo nisi.</p>',
'meta_title' => 'Blog 2',
'meta_keywords' => '',
'meta_description' => '',
@@ -66,7 +66,7 @@ public function get_blog( $id = 0 )
'url' => 'blog3',
'date' => strtotime('January 20, 2012'),
'name' => 'Blog 3',
- 'content' => '<p>Sed posuere consectetur est at lobortis. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.</p>',
+ 'content' => '<p>Sed posuere consectetur est at lobortis. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh. Fusce malesuada congue quam mollis ullamcorper. Nulla est purus, consequat vitae rutrum quis, iaculis id augue. Mauris a vehicula enim.</p><p>Pellentesque quis turpis mi, eget lobortis nisl. Maecenas congue, dolor eu adipiscing egestas, felis ipsum commodo est, commodo hendrerit eros est vulputate lacus. Donec iaculis, nisl pretium interdum ornare, lacus odio luctus mi, et venenatis elit elit eget mi.</p>',
'meta_title' => 'Blog 3',
'meta_keywords' => '',
'meta_description' => '',
@@ -77,7 +77,7 @@ public function get_blog( $id = 0 )
'url' => 'blog4',
'date' => strtotime('January 26, 2012'),
'name' => 'Blog 4',
- 'content' => '<p>Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>',
+ 'content' => '<p>Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce dui justo, sollicitudin a auctor a, pulvinar eget lectus. Etiam tincidunt varius facilisis.</p><p>In vestibulum, leo eu malesuada mattis, odio quam elementum diam, at facilisis enim lacus sit amet erat. Maecenas nisi arcu, rhoncus eu lacinia in, lobortis in nunc. Nullam ac sem id enim viverra vestibulum ullamcorper at metus. Pellentesque laoreet mattis cursus.</p>',
'meta_title' => 'Blog 4',
'meta_keywords' => '',
'meta_description' => '',
View
14 app/front/models/forms.model.php
@@ -14,10 +14,11 @@ public function get_form( $id = 0 )
'type' => 'horizontal',
'content' => '<p>Thank you for filling out our contact form.</p>',
'fields' => array(
- array('id' => 1, 'required' => 1, 'label' => 'Name', 'type' => 'text_input'),
- array('id' => 2, 'required' => 0, 'label' => 'Email', 'type' => 'text_input'),
- array('id' => 3, 'required' => 1, 'label' => 'Some options', 'type' => 'select', 'options' => array('option 1', 'option 2', 'option 3')),
- array('id' => 4, 'required' => 1, 'label' => 'Questions / Comments', 'type' => 'textarea')
+ array('id' => 1, 'required' => 0, 'label' => 'Contact Us', 'type' => 'heading'),
+ array('id' => 2, 'required' => 1, 'label' => 'Name', 'type' => 'text_input'),
+ array('id' => 3, 'required' => 0, 'label' => 'Email', 'type' => 'text_input'),
+ array('id' => 4, 'required' => 1, 'label' => 'Some options', 'type' => 'select', 'options' => array('option 1', 'option 2', 'option 3')),
+ array('id' => 5, 'required' => 1, 'label' => 'Questions / Comments', 'type' => 'textarea')
)
);
return $arr;
@@ -30,8 +31,9 @@ public function get_form( $id = 0 )
'type' => '',
'content' => '<p>Thanks for signing up for the newsletter.</p>',
'fields' => array(
- array('id' => 5, 'required' => 1, 'label' => 'Name', 'type' => 'text_input'),
- array('id' => 6, 'required' => 1, 'label' => 'Email', 'type' => 'text_input'),
+ array('id' => 6, 'required' => 0, 'label' => 'Newsletter', 'type' => 'heading'),
+ array('id' => 7, 'required' => 1, 'label' => 'Name', 'type' => 'text_input'),
+ array('id' => 8, 'required' => 1, 'label' => 'Email', 'type' => 'text_input'),
)
);
return $arr;
View
65 app/front/models/layouts.model.php
@@ -2,6 +2,24 @@
class layouts_model extends model
{
+ /*
+ The layouts templates are pieced together using the "controller" and the "skin"
+ format: CONTROLLER.SKIN.layout.php
+
+ The "controller" variable tells the router which controller to load.
+ Default controller is "pages".
+ The modular controllers like "blogs" will replace the block '[content]' with the appropriate modular data.
+
+ The "skin" just defines which layout to use. This way you can use different layouts for seperate sections under a single module.
+ An example is the landing page for the blog (blogs.default.layout.php) has one large column and a thin right column,
+ then the blog post page (blogs.post.layout.php) will have a skinny column for social stuff, a middle column, and
+ then a thin right column.
+
+ The "cells" contain all the blocks that have been added to it.
+ Most blocks will have a format like '[blocks:6]'. This tells the "controller->parse_page_layout()" method to load the
+ "blocks" controller (then call the "get_block()" method) and pass "6" as the argument and replace '[blocks:6]' with
+ whatever gets returned.
+ */
public function get_layout( $id = 0 )
{
@@ -12,84 +30,81 @@ public function get_layout( $id = 0 )
case 1: // home
$arr = array(
'controller' => '',
+ 'skin' => 'home',
'cells' => array(
1 => array('[content]'),
- 2 => array('[blocks:6]'),
- 3 => array('[blocks:2]'),
- 4 => array('[blogs:4]'),
- 5 => array('[forms:2]'),
- 6 => array('[blogs:recent.block]')
+ 2 => array('[blocks:2]'),
+ 3 => array('[blogs:4]'),
+ 4 => array('[forms:2]'),
+ 5 => array('[blogs:recent]'),
+ 6 => array('[blogs:recent.green]'),
+ 7 => array('[blogs:4.full]')
)
);
break;
case 2: // about
$arr = array(
'controller' => '',
+ 'skin' => 'skin1',
'cells' => array(
1 => array('[content]'),
2 => array('[blocks:1]', '[blocks:2]'),
- 3 => array('[blocks:2]'),
- 4 => array('[blocks:3]'),
- 5 => array('[blocks:4]'),
- 6 => array('[blocks:5]')
+ 3 => array('<h3>HTML Block</h3><p>This is written directly into the layout of this page without being added to the Blocks module.</p><p>Mauris varius accumsan orci, eu venenatis eros venenatis nec. Curabitur eu ipsum mauris. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>'),
+ 4 => array('<h3>Another HTML Block</h3><p>Cras quam nisl, mattis eu vestibulum sed, commodo a tellus. Integer nunc nisl, fringilla sed fermentum sit amet, commodo at sapien. Ut nibh orci, volutpat eget ultrices at, aliquet porttitor lectus. Aliquam egestas gravida egestas</p>')
)
);
break;
case 3: // blog
$arr = array(
'controller' => 'blogs',
+ 'skin' => '',
'cells' => array(
- //1 => array('[content]','[blogs:content]'),
1 => array('[content]'),
- 2 => array('[blocks:1]','[blogs:subscribe.block]','[blocks:3]','[blogs:categories.block]','[blogs:recent.block]')
+ 2 => array('[blocks:1]','[blogs:subscribe]','[blocks:3]','[blogs:categories]','[blogs:recent]')
)
);
break;
case 4: // contact
$arr = array(
'controller' => '',
+ 'skin' => '',
'cells' => array(
1 => array('[content]','[forms:1]'),
- 2 => array('[blocks:6]','[forms:2]'),
- 3 => array(),
- 4 => array(),
- 5 => array('[blocks:3]'),
- 6 => array('[forms:2]')
+ 2 => array('[blocks:6]','[forms:2]','[forms:2]')
)
);
break;
case 5: // error
$arr = array(
'controller' => '',
+ 'skin' => '',
'cells' => array(
1 => array('[content]'),
- 2 => array('[blocks:6]'),
- 3 => array('[blocks:1]'),
- 4 => array('[blocks:2]'),
- 5 => array('[blocks:3]'),
- 6 => array('[forms:2]')
+ 2 => array('[blocks:6]')
)
);
break;
- case 6: // blogs > blog 1, 2, 3, 4
+ case 6: // blog1, blog2, blog3, blog4
$arr = array(
'controller' => 'blogs',
+ 'skin' => 'post',
'cells' => array(
- //1 => array('[blogs:content]', '[content]'),
- 1 => array('[content]', '[blocks:1]'),
- 2 => array('[blogs:subscribe.block]','[blogs:categories.block]','[blogs:recent.block]')
+ 1 => array('[blocks:7]'),
+ 2 => array('[content]'),
+ 3 => array('[blogs:subscribe]','[blogs:recent]','[blocks:1]','[blogs:categories]')
)
);
break;
default: // default layout for pages without one
$arr = array(
'controller' => '',
+ 'skin' => '',
'cells' => array(
1 => array('[content]')
)
View
4 index.php
@@ -10,7 +10,9 @@
define('DEFAULT_CONTROLLER', 'pages');
define('DEFAULT_SKIN', 'default');
define('ERROR_CONTROLLER', 'error');
-define('DEFAULT_MAIN_TEMPLATE', 'layout.main.template.php');
+define('DEFAULT_HEADER_TEMPLATE', 'header.layout.php');
+define('DEFAULT_LAYOUT_TEMPLATE', 'pages.default.layout.php');
+define('DEFAULT_FOOTER_TEMPLATE', 'footer.layout.php');
// LOAD APP FUNCTIONS & OVERRIDES
$path = SITE_ROOT . '/app/' . APP . '/core/functions.php';
View
4 ...s/front/default/layout.blogs.template.php → skins/front/default/blogs.default.layout.php
@@ -1,4 +1,3 @@
-<?= load_view('header.template.php'); ?>
<div id="main">
<div id="main_content">
@@ -29,5 +28,4 @@
</div>
</div>
-
-<?= load_view('footer.template.php'); ?>
+
View
45 skins/front/default/blogs.post.layout.php
@@ -0,0 +1,45 @@
+
+ <div id="main">
+ <div id="main_content">
+
+ <div class="row">
+
+ <div class="span2"><!-- cell 1 -->
+
+ <?php if ($layout['cells'][1]) : ?>
+ <?php foreach( $layout['cells'][1] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+
+ </div>
+
+ <div class="span7"><!-- cell 2 -->
+
+ <?php if ($layout['cells'][2]) : ?>
+ <?php foreach( $layout['cells'][2] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+
+ </div>
+
+ <div class="span3"><!-- cell 3 -->
+ <?php if ($layout['cells'][3]) : ?>
+ <?php foreach( $layout['cells'][3] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+ </div>
+
+ </div>
+
+ </div>
+ </div>
+
View
17 skins/front/default/css/blogs.css
@@ -31,6 +31,14 @@
/* blogs blocks */
+.blogs_blog_block {
+ margin-bottom: 20px;
+}
+.blogs_blog_full {
+ margin-bottom: 20px;
+ padding: 10px;
+ background-color: #EEE8AA;
+}
.blogs_subscribe_block {
margin-bottom: 20px;
}
@@ -40,4 +48,13 @@
.blogs_recent_block {
margin-bottom: 20px;
}
+.blogs_recent_block2 {
+ margin-bottom: 20px;
+ padding: 10px;
+ color: #fff;
+ background-color: #51A351;
+}
+.blogs_recent_block2 a {
+ color: #fff !important;
+}
View
20 skins/front/default/css/forms.css
@@ -1,11 +1,19 @@
+
-.form_submitted {
+/* forms blocks */
+.forms_block {
+ margin-bottom: 20px;
+}
+.forms_block_submitted {
+ margin-bottom: 20px;
padding: 10px;
background-color: #e3e3cf;
}
+
+
/* form fields */
.input_container {
margin-bottom: 9px;
@@ -82,6 +90,16 @@ select {
+/* textual forms elements */
+.input_heading {
+ margin-bottom: 5px;
+ font-size: 14px;
+ font-weight: bold;
+ border-bottom: 1px solid #ccc;
+}
+
+
+
/* form buttons */
.form_horizontal .form_actions {
margin-left: 160px;
View
0 skins/front/default/footer.template.php → skins/front/default/footer.layout.php
File renamed without changes.
View
0 skins/front/default/header.template.php → skins/front/default/header.layout.php
File renamed without changes.
View
35 skins/front/default/pages.default.layout.php
@@ -0,0 +1,35 @@
+
+ <div id="main">
+ <div id="main_content">
+
+ <div class="row">
+
+ <div class="span8"><!-- cell 1 -->
+
+ <?php if ($layout['cells'][1]) : ?>
+ <?php foreach( $layout['cells'][1] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+
+ </div>
+
+ <div class="span4"><!-- cell 2 -->
+
+ <?php if ($layout['cells'][2]) : ?>
+ <?php foreach( $layout['cells'][2] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+
+ </div>
+
+ </div>
+
+ </div>
+ </div>
+
View
18 skins/front/default/layout.main.template.php → skins/front/default/pages.home.layout.php
@@ -1,4 +1,3 @@
-<?= load_view('header.template.php'); ?>
<div id="main">
<div id="main_content">
@@ -73,7 +72,20 @@
</div>
+ <div class="row">
+
+ <div class="span12"><!-- cell 7 -->
+ <?php if ($layout['cells'][7]) : ?>
+ <?php foreach( $layout['cells'][7] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+ </div>
+
+ </div>
+
</div>
</div>
-
-<?= load_view('footer.template.php'); ?>
+
View
61 skins/front/default/pages.skin1.layout.php
@@ -0,0 +1,61 @@
+
+ <div id="main">
+ <div id="main_content">
+
+ <div class="row">
+
+ <div class="span8"><!-- cell 1 -->
+
+ <?php if ($layout['cells'][1]) : ?>
+ <?php foreach( $layout['cells'][1] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+
+ </div>
+
+ <div class="span4"><!-- cell 2 -->
+ <?php if ($layout['cells'][2]) : ?>
+ <?php foreach( $layout['cells'][2] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+ </div>
+
+ </div>
+
+ <div class="row">
+
+ <div class="span6"><!-- cell 3 -->
+
+ <?php if ($layout['cells'][3]) : ?>
+ <?php foreach( $layout['cells'][3] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+
+ </div>
+
+ <div class="span6"><!-- cell 4 -->
+
+ <?php if ($layout['cells'][4]) : ?>
+ <?php foreach( $layout['cells'][4] as $block ) : ?>
+ <?= $block; ?>
+ <?php endforeach; ?>
+ <?php else : ?>
+ <p>&nbsp;</p>
+ <?php endif; ?>
+
+ </div>
+
+ </div>
+
+ </div>
+ </div>
+
View
0 skins/front/default/blocks.blue.template.php → ...t/default/templates/blocks.blue.block.php
File renamed without changes.
View
0 ...front/default/blocks.default.template.php → ...efault/templates/blocks.default.block.php
File renamed without changes.
View
0 ...s/front/default/blocks.green.template.php → .../default/templates/blocks.green.block.php
File renamed without changes.
View
0 ...ont/default/blogs.blog.block.template.php → ...mplates/blogs/bak/blog.block.template.php
File renamed without changes.
View
12 skins/front/default/templates/blogs/bak/blog.full.template.php
@@ -0,0 +1,12 @@
+
+ <?php if ( count($blog) ) : ?>
+
+ <div class="blogs_blog_full">
+ <h3><?= $blog['name']; ?></h3>
+ <p><?= date('M d, Y', $blog['date']); ?></p>
+ <p><?= $blog['content']; ?></p>
+ <p><a href="<?= $link . $blog['url']; ?>">go there now...</a></p>
+ </div>
+
+ <?php endif; ?>
+
View
0 ...fault/blogs.categories.block.template.php → ...s/blogs/bak/categories.block.template.php
File renamed without changes.
View
0 ...t/default/blogs.recent.block.template.php → ...lates/blogs/bak/recent.block.template.php
File renamed without changes.
View
11 skins/front/default/templates/blogs/bak/recent.block2.template.php
@@ -0,0 +1,11 @@
+
+ <div class="blogs_recent_block2">
+ <h3>Recent Blogs 2</h3>
+ <ul>
+ <li><a href="<?= $link; ?>blog4">Donec id elit non mi</a></li>
+ <li><a href="<?= $link; ?>blog3">Porta gravida at eget metus</a></li>
+ <li><a href="<?= $link; ?>blog2">Vivamus sagittis lacus vel augue laoreet rutrum</a></li>
+ <li><a href="<?= $link; ?>blog1">At eget metus</a></li>
+ </ul>
+ </div>
+
View
0 ...efault/blogs.subscribe.block.template.php → ...es/blogs/bak/subscribe.block.template.php
File renamed without changes.
View
12 skins/front/default/templates/blogs/blog.default.block.php
@@ -0,0 +1,12 @@
+
+ <?php if ( count($blog) ) : ?>
+
+ <div class="blogs_blog_block">
+ <h3><?= $blog['name']; ?></h3>
+ <p><?= date('M d, Y', $blog['date']); ?></p>
+ <p><?= substr(strip_tags($blog['content']), 0, 100); ?>...</p>
+ <p><a href="<?= $link . $blog['url']; ?>">Read on</a></p>
+ </div>
+
+ <?php endif; ?>
+
View
12 skins/front/default/templates/blogs/blog.full.block.php
@@ -0,0 +1,12 @@
+
+ <?php if ( count($blog) ) : ?>
+
+ <div class="blogs_blog_full">
+ <h3><?= $blog['name']; ?></h3>
+ <p><?= date('M d, Y', $blog['date']); ?></p>
+ <p><?= $blog['content']; ?></p>
+ <p><a href="<?= $link . $blog['url']; ?>">go there now...</a></p>
+ </div>
+
+ <?php endif; ?>
+
View
10 skins/front/default/templates/blogs/categories.default.block.php
@@ -0,0 +1,10 @@
+
+ <div class="blogs_categories_block">
+ <h3>Categories Block</h3>
+ <ul>
+ <li>Donec</li>
+ <li>Elit non</li>
+ <li>Mi porta gravida</li>
+ </ul>
+ </div>
+
View
0 .../front/default/blogs.landing.template.php → ...efault/templates/blogs/index.template.php
File renamed without changes.
View
11 skins/front/default/templates/blogs/recent.default.block.php
@@ -0,0 +1,11 @@
+
+ <div class="blogs_recent_block">
+ <h3>Recent Blogs</h3>
+ <ul>
+ <li><a href="<?= $link; ?>blog4">Donec id elit non mi</a></li>
+ <li><a href="<?= $link; ?>blog3">Porta gravida at eget metus</a></li>
+ <li><a href="<?= $link; ?>blog2">Vivamus sagittis lacus vel augue laoreet rutrum</a></li>
+ <li><a href="<?= $link; ?>blog1">At eget metus</a></li>
+ </ul>
+ </div>
+
View
11 skins/front/default/templates/blogs/recent.green.block.php
@@ -0,0 +1,11 @@
+
+ <div class="blogs_recent_block2">
+ <h3>Recent Blogs 2</h3>
+ <ul>
+ <li><a href="<?= $link; ?>blog4">Donec id elit non mi</a></li>
+ <li><a href="<?= $link; ?>blog3">Porta gravida at eget metus</a></li>
+ <li><a href="<?= $link; ?>blog2">Vivamus sagittis lacus vel augue laoreet rutrum</a></li>
+ <li><a href="<?= $link; ?>blog1">At eget metus</a></li>
+ </ul>
+ </div>
+
View
5 skins/front/default/templates/blogs/subscribe.default.block.php
@@ -0,0 +1,5 @@
+
+ <div class="blogs_subscribe_block">
+ <h3><a href="<?= $link; ?>rss">RSS SUBSCRIBE</a></h3>
+ </div>
+
View
0 skins/front/default/blogs.view.template.php → ...default/templates/blogs/view.template.php
File renamed without changes.
View
23 skins/front/default/templates/forms.default.block.php
@@ -0,0 +1,23 @@
+
+ <?php if ($submitted) : // if the form was submitted successfully ?>
+
+ <div class="forms_block_submitted">
+ <a name="<?= $name; ?>"></a>
+ <?= $content; ?>
+ </div>
+
+ <?php elseif ($fields != '') : // else, display the form as long as there are fields ?>
+
+ <div class="forms_block">
+ <div class="<?= ($type == 'horizontal' ? 'form_horizontal' : '') ?>">
+ <form id="<?= $name; ?>" action="<?= $action; ?>" method="post">
+ <?= $fields; ?>
+ <div class="form_actions">
+ <button type="submit" class="btn">Submit</button>
+ </div>
+ </form>
+ </div>
+ </div>
+
+ <?php endif; ?>
+
View
0 .../front/default/pages.content.template.php → ...ault/templates/pages.content.template.php
File renamed without changes.

0 comments on commit b7bd88a

Please sign in to comment.
Something went wrong with that request. Please try again.