Created
March 27, 2012 04:17
-
-
Save zeelot/2212507 to your computer and use it in GitHub Desktop.
Top navigation with selected status (change dashes for slashes as gists do not allow directories)
This file contains 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 View_Page_Browse extends View_Page { | |
// On this page, 'browse' tab is selected | |
protected $_selected_top_nav_item = 'browse'; | |
} |
This file contains 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 View_Page_Home extends View_Page { | |
// On this page, 'home' tab is selected | |
protected $_selected_top_nav_item = 'home'; | |
} |
This file contains 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 View_Page extends Kostache { | |
// Decides which nav item is selected | |
protected $_selected_top_nav_item; | |
public function top_nav() | |
{ | |
// Return the nav array with url and selected status | |
return array( | |
array( | |
'url' => Route::url('home', ...), // Generate the url using reverse routing | |
'text' => 'Home', | |
'selected' => $this->_selected_top_nav_item === 'home', | |
), | |
array( | |
'url' => Route::url('browse', ...), // Generate the url using reverse routing | |
'text' => 'Browse', | |
'selected' => $this->_selected_top_nav_item === 'browse', | |
), | |
); | |
} | |
} |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<ul class="top-nav"> | |
{{#top_nav}} | |
<li{{#selected}} class="selected"{{/selected}}><a href="{{url}}">{{text}}</a></li> | |
{{/top_nav}} | |
</ul> | |
<h1>{{title}}</h1> | |
<p>{{>content}}</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment