All notable changes to menu
will be documented in this file.
- Make
->setExactActive()
accept a callable as well by @ralphjsmit in #146
- @ralphjsmit made their first contribution in #146
Full Changelog: https://github.com/spatie/menu/compare/3.1.1...3.2.0
- fix active classes
- Add
id
to docs by @milwad-dev in #144
Full Changelog: https://github.com/spatie/menu/compare/3.1.0...3.1.1
- typofix in item-attributes.md by @davidjr82 in #138
- Add PHP 8.2 Support by @patinthehat in #141
- Refactor tests to pest by @AyoobMH in #142
- Add
id
attribute for menu by @milwad-dev in #143
- @davidjr82 made their first contribution in #138
- @AyoobMH made their first contribution in #142
- @milwad-dev made their first contribution in #143
Full Changelog: https://github.com/spatie/menu/compare/3.0.1...3.1.0
- Support PHP 8+
- Drop support for PHP 7.x
- Use PHP 8 syntax where possible
- Ensure
Items
are transformed to string before prepending or appending
- Fix
methods_exists
check in PHP8
- Ensure the necessary methods exist to check if a menu is active
- Support
Item
instances inMenu::prepend
so headers can be set active
- Drop support for versions older than PHP 7.1
- Add
exact-active
class to links that exactly match the current URL. This is accompanied by asetExactActiveClass(string $class)
method to set the class name
- Add
IteratorAggregate
interface toMenu
class
- Add
beforeRender
andwillRender
hooks that are called when an item is rendered
- This release adds a few methods to create non-
ul
menus, which allows for Bootstrap 4 compatibility - Added
Menu::setWrapperTag
andMenu::withoutWrapperTag
to set a custom wrapper tag name for the menu list. Default:ul
- Added
Menu::setParentTag
&Menu::withoutParentTag
to determine which tag should be used for the item's parent element. Default:li
- Added
Menu::setActiveClassOnLink
andMenu::setActiveClassOnParent
to determine where the active class should be applied
- Allow invokable classes as callbacks
- Added
Menu::empty
andHtml::empty
method for adding empty list items
- Extracted a
ActiveUrlChecker
class for public use
- Added
append
andprepend
methods toLink
- Fixed returning a menu instance is now optional with
fill
andbuild
- Fixed setting items active with urls that start with the same string
- Added
if
function
- Fixed setting an active url when the url is exactly the same
- Added the request root path when setting the active path
- Added optional third
$initial
parameter inMenu::build
- Fixed require
^1.0.0
of spatie/url
- Added added the static
Menu::build
and non-staticMenu::fill
methods to create menu's from arrays. - Added the
setActive
method onActivatable
now also accepts a non-strict boolean or callable parameter to set$active
to true or false. - Added
Menu::html
andMenu::htmlIf
now accept a$parentAttributes
array as their second arguments. - Changed the
HtmlAttributes
andParentAttributes
traits have been renamed toHasHtmlAttributes
andHasParentAttributes
. - Changed the
HasUrl
interface and trait has been removed. Url-related methods now also are part of theActivatable
interface and trait. - Removed the
void
andvoidIf
have been removed. These can be replaced byhtml
andhtmlIf
, with empty strings as their first arguments - Removed the
prefixLinks
andprefixUrls
methods have been removed because they were too unpredictable in some case. There currently isn't an alternative for these, besides writing your own logic and applying it withapplyToAll
.
- Added a
HasUrl
trait - Deprecated
prefixLinks
in favor ofprefixUrls
- Added
submenuIf
- Internal refactors
- New methods on
Menu
: -
submenu
for submenus with optional headers
-
void
andvoidIf
for empty list items
-
wrap
to wrap the menu in an html tag with optional attributes
-
- A
blueprint
method to copy the menu without it's contents
- A
-
- Html item convenience methods:
addItemClass
,setItemAttribute
- Html item convenience methods:
-
- Html parent convenience methods:
addItemParentClass
,setItemParentAttribute
- Html parent convenience methods:
- Added
HasHtmlAttributes
andHasParentAttributes
interfaces HtmlAttributes
andParentAttributes
now also have asetAttributes
method
- Fixed
setActive
when setting active from a URL
- Added conditional
add
functions,addIf
,linkIf
andhtmlIf
- First release