Created
February 23, 2012 00:47
-
-
Save highruned/1888794 to your computer and use it in GitHub Desktop.
LemonStand Partial - site:breadcrumb
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
| <? | |
| $nodes = array(); | |
| $params = array(); | |
| $parents = $this->page->navigation_parents(false); | |
| foreach($parents as $parent) { | |
| $page_obj = Cms_Page::findByUrl($parent->url, $params); | |
| $add_node = true; | |
| switch($page_obj->action_reference) { | |
| case 'shop:category': | |
| case 'shop:product': | |
| case 'blog:category': | |
| $add_node = false; | |
| } | |
| if ($add_node) { | |
| $nodes[root_url($page_obj->url)] = $page_obj->navigation_label(); | |
| } | |
| } | |
| switch ($this->page->action_reference) { | |
| case 'blog:post': | |
| if(isset($post)) { | |
| $nodes[root_url('/news/category/'.$post->categories[0]->url_name)] = $post->categories[0]->name; | |
| $nodes[root_url('/news/post/'.$post->url_title)] = $post->title; | |
| } | |
| break; | |
| case 'blog:category': | |
| if(isset($category)) | |
| $nodes[root_url('/news/category/'.$category->url_name)] = $category->name; | |
| break; | |
| case 'shop:category': | |
| if(isset($category)) { | |
| $category_nodes = $category->get_parents(false); | |
| foreach($category_nodes as $node) | |
| $nodes[$node->page_url('/store/category')] = $node->name; | |
| } | |
| break; | |
| case 'shop:product': | |
| if(isset($product)) { | |
| $category_nodes = $product->category_list[count($product->category_list)-1]->get_parents(true); | |
| foreach($category_nodes as $node) | |
| $nodes[$node->page_url('/store/category')] = $node->name; | |
| } | |
| break; | |
| } | |
| $navigation_nodes = array(); | |
| foreach($nodes as $url => $title) { | |
| $navigation_nodes[] = "<a href=\"{$url}\">{$title}</a>"; | |
| } | |
| // don't append current page node if it's a known dynamic page | |
| switch ($this->page->action_reference) { | |
| case 'blog:post': | |
| case 'blog:category': | |
| case 'shop:category': | |
| case 'shop:product': | |
| break; | |
| default: | |
| $navigation_nodes[] = '<a href="'.Phpr::$request->getCurrentUri().'" class="current">' . $this->page->navigation_label() ? $this->page->navigation_label() : $this->page->title . '</a>'; | |
| break; | |
| } | |
| ?> | |
| <?= join(' » ', $navigation_nodes) ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment