Skip to content
Browse files

Deprecated add and add_if, and updated readme.

  • Loading branch information...
1 parent ec3e54f commit 8170c52a3513fe991667a2ee0e7a6648b118fb5e @sparksp committed
Showing with 59 additions and 10 deletions.
  1. +34 −1 menu.php
  2. +25 −9 readme.md
View
35 menu.php
@@ -13,7 +13,7 @@
* ->divider('', array('class' => 'divider'))
* ->link('about', 'About')
* ->link('contact', 'Contact')
- * ->get();
+ * ->render();
* </code>
*
* @category Bundle
@@ -330,6 +330,39 @@ function get($type = null)
return $this->render($type);
}
+ /**
+ * Add an link to the menu
+ *
+ * @deprecated
+ * @param string $url
+ * @param string $title
+ * @param array $attributes
+ * @param bool $https
+ * @return Menu
+ */
+ function add($url, $title, array $attributes = array(), $https = false)
+ {
+ trigger_error('Deprecated: $menu->add() is deprecated, please use $menu->link() instead.', E_USER_DEPRECATED);
+ return $this->add($url, $title, $attributes, $https);
+ }
+
+ /**
+ * Add an link if the test is true
+ *
+ * @deprecated
+ * @param bool|callback $test
+ * @param string $url
+ * @param string $title
+ * @param array $attributes
+ * @param bool $https
+ * @return Menu
+ */
+ function add_if($test, $url, $title, $attributes = array(), $https = false)
+ {
+ trigger_error('Deprecated: $menu->add_id() is deprecated, please use $menu->link_if() instead.', E_USER_DEPRECATED);
+ return $this->link_if($test, $url, $title, $attributes, $https);
+ }
+
}
/**
View
34 readme.md
@@ -34,24 +34,40 @@ Generate a simple navigation menu ('ul' is default):
```php
echo Topos\Menu::make(array('class' => 'menu'), 'ol')
- ->add('', 'Home')
- ->add('blog', 'Blog')
- ->add('about', 'About')
- ->add('contact', 'Contact')
+ ->link('', 'Home')
+ ->link('blog', 'Blog')
+ ->link('about', 'About')
+ ->link('contact', 'Contact')
->render();
```
### Optional menu items
-You can also use `->add_if($test, $url, $label)` to conditionally add items, test can be any callback or boolean.
+You can also use `->link_if($test, $url, $label)` to conditionally add items, test can be any callback or boolean.
```php
echo Topos\Menu::make()
- ->add('', 'Home')
- ->add('blog', 'Blog')
+ ->link('', 'Home')
+ ->link('blog', 'Blog')
// Only show the admin item if we're in admin area
- ->add_if(URI::is('admin(/*)?'), 'admin', 'Admin')
+ ->link_if(URI::is('admin(/*)?'), 'admin', 'Admin')
// Only show the logout link if we're logged in
- ->add_if(Auth::check(), 'logout', 'Logout')
+ ->link_if(Auth::check(), 'logout', 'Logout')
+ ->render();
+```
+
+### Dividers
+
+You can use `->divider($title, $attributes)` to add dividers (non-link items); useful for sidebar menus.
+
+```php
+echo Topos\Menu::make()
+ ->divider('Section 1')
+ ->link('', 'Home')
+ ->link('blog', 'Blog')
+ // Only show Section 2 if we're logged in
+ ->divider_if(Auth::check(), 'Section 2')
+ ->link_if(Auth::check(), 'me', 'Profile')
+ ->link_if(Auth::check(), 'logout', 'Logout')
->render();
```

0 comments on commit 8170c52

Please sign in to comment.
Something went wrong with that request. Please try again.