Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added breadcrumbs method

  • Loading branch information...
commit 27828c2163195c565635a9f1c751905d186f2e2c 1 parent 9d36522
@Pagebakers authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 navigation.php
View
32 navigation.php
@@ -60,6 +60,38 @@ function menu($items, $attributes = array()) {
}
/**
+ * Returns a formatted <ul> with links
+ * @param array $items An array containing all children for the list
+ * @param array $options The html attributes for the list
+ * @return string The formatted <ul> list
+ */
+ function breadcrumbs($items, $attributes = array()) {
+ if(!is_array($items) || empty($items)) {
+ return;
+ }
+
+ $links = array();
+ $i = 1;
+ $count = count($items);
+ foreach($items as $item) {
+ if(count($item) == 2) {
+ list($text, $url) = $item;
+ $itemOptions = array();
+ } else {
+ list($text, $url, $itemOptions) = $item;
+ }
+ if($i < $count) {
+ $links[] = sprintf($this->tags['li'], '', parent::link($text, $url, $itemOptions));
+ } else {
+ $links[] = sprintf($this->tags['li'], ' class="last"', sprintf('<span%s>%s</span>', $this->_parseAttributes($itemOptions), $text));
+ }
+ $i++;
+ }
+
+ return sprintf($this->tags['ul'], $this->_parseAttributes($attributes, null, ' ', ''), implode("\n", $links));
+ }
+
+ /**
* Returns a link with class="active" if the url is the currently active url
* @param string $title The content to be wrapped in <a/>
* @param string $url The url of the link
Please sign in to comment.
Something went wrong with that request. Please try again.