菜单订购/管理应用程序演示,例如 Wordpress 菜单管理器
See demo at: http://laravel-menu-builder.gopagoda.com/admin/menu Tutorial coming up at: http://maxoffsky.com
This application demonstrates usage of Nestable plugin jQuery plugin to provide the user with nice menu ordering experience without a page refresh:
The menu controller is in app/controllers/Admin/MenuController.php The menu model is in app/models/Menu.php
The important columns of the "menus" table are:
With these 3 fields we can build nested menus as many levels deep as you want. The Nestable plugin helps modify the values of these fields for the appropriate rows of data.
The hard part that took me a looong time to build is a very small function inside of app/models/Menu.php:
public function buildMenu($menu, $parentid = 0)
{
$result = null;
foreach ($menu as $item)
if ($item->parent_id == $parentid) {
$result .= "
order}' data-id='{$item->id}'>
".$this->buildMenu($menu, $item->id) . "
";
}
return $result ? "\n
\n$result
\n" : null;
}
This function uses recursion to display the menu to the user even if the menu is many many levels deep. This function alone can save you a bunch of time.
The more people star my repos - the more I will give back to the community.
I post tutorials all the time on my blog : http://maxoffsky.com, stay updated on my Twitter: http://twitter.com/msurguy
The Laravel menu manager is open-sourced software licensed under the MIT license
暂无开放 Issues,或尚未同步最近议题。