diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-19 04:18:15 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-19 04:18:15 +0000 |
commit | 10b71502f8770c29a4d79266f1f242bd136e78ce (patch) | |
tree | 3d3d2a1ae186e17afb3b70de7a4e68f98a122cf6 /engine | |
parent | b5e2bf119e91ec16b9df6eb35ff58b13390fecef (diff) | |
download | elgg-10b71502f8770c29a4d79266f1f242bd136e78ce.tar.gz elgg-10b71502f8770c29a4d79266f1f242bd136e78ce.tar.bz2 |
Added 4 methods to ElggMenuItem: get/setLinkClass() and get/setItemClass(). This allows you to put classes on the a and li tags it generates.
git-svn-id: http://code.elgg.org/elgg/trunk@8313 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/classes/ElggMenuItem.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 108cb56f2..0de5feddb 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -24,6 +24,16 @@ class ElggMenuItem { protected $url = null; /** + * @var array Classes to apply to the anchor tag. + */ + protected $linkClass = array(); + + /** + * @var array Classes to apply to the li tag. + */ + protected $itemClass = array(); + + /** * @var array Page context array */ protected $contexts = array('all'); @@ -232,6 +242,54 @@ class ElggMenuItem { } /** + * Set the anchor class + * + * @param mixed $class An array of class names, or a single string class name. + * + * @return void + */ + public function setLinkClass($class) { + if (!is_array($class)) { + $this->linkClass[] = $class; + } else { + $this->linkClass = $class; + } + } + + /** + * Get the anchor classes as text + * + * @return string + */ + public function getLinkClass() { + return implode(' ', $this->linkClass); + } + + /** + * Set the li classes + * + * @param mixed $class An array of class names, or a single string class name. + * + * @return void + */ + public function setItemClass($class) { + if (!is_array($class)) { + $this->itemClass[] = $class; + } else { + $this->itemClass = $class; + } + } + + /** + * Get the li classes as text + * + * @return string + */ + public function getItemClass() { + return implode(' ', $this->itemClass); + } + + /** * Set the weight of the menu item * * @param int $weight The lower weight items float to the top of the menu @@ -354,6 +412,9 @@ class ElggMenuItem { if ($this->url) { $vars['href'] = $this->url; } + if ($this->linkClass) { + $vars['class'] = $this->linkClass; + } return elgg_view('output/url', $vars); } |