Created
October 17, 2011 17:24
-
-
Save tarnfeld/1293169 to your computer and use it in GitHub Desktop.
Magicload class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Magicload { | |
| protected static $_data = array(); | |
| /** | |
| * The index action. | |
| * | |
| * @access public | |
| * @return void | |
| */ | |
| public static function load($view = false) | |
| { | |
| if(!$view) return false; | |
| self::$_data['includes']['nav'] = self::createLinks(); | |
| self::$_data['includes']['header'] = View::factory('includes/header', self::$_data, false); | |
| self::$_data['includes']['footer'] = View::factory('includes/footer', self::$_data, false); | |
| return View::factory($view, self::$_data); | |
| } | |
| protected static function createLinks() | |
| { | |
| $links = array( | |
| 'home'=>array('link'=>'/','title'=>'Find out more about Basildon Timber Merchants','display'=>'about us'), | |
| 'news'=>array('link'=>'/page/news','title'=>'Find out the latest Basildon Timber News','display'=>'news'), | |
| 'products'=>array('link'=>'/page/products','title'=>'See Basildon Timber\'s Products That Are Available To Buy','display'=>'products'), | |
| 'shop'=>array('link'=>'/page/shop','title'=>'Basildon Timber have a shop with wide range of tools and materials to suit your needs','display'=>'shop'), | |
| 'directions'=>array('link'=>'/page/directions','title'=>'Get Directions For Timber in Basildon','display'=>'directions'), | |
| 'contact'=>array('link'=>'/page/contact','title'=>'Contact Details for Basildon Timber','display'=>'contact'), | |
| ); | |
| $class = $output = ''; | |
| $page = Uri::segment(2); | |
| foreach($links as $key=>$link): | |
| $class = $page == $key || ($page && $key == 'home') ? ' class="current"' : ''; | |
| $output .= '<li '.$class.'><a href="'.$link['link'].'" title="'.$link['title'].'">'.$link['display'].'</a></li>'; | |
| endforeach; | |
| echo $output; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment