All Projects → davicotico → PHP-Quick-Menu

davicotico / PHP-Quick-Menu

Licence: GPL-3.0 license
This is a PHP Multilevel Menu class. From nested Json|Array to Html menu (ul)

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to PHP-Quick-Menu

django-menu-generator
A straightforward menu generator for Django
Stars: ✭ 24 (-4%)
Mutual labels:  menubar, menu-generator, menu-navigation, menu-item
Vue Dock Menu
⚓Dockable Menu bar for Vue
Stars: ✭ 183 (+632%)
Mutual labels:  menubar, menus
vue-bottom-navigation
Vue bottom navigation
Stars: ✭ 56 (+124%)
Mutual labels:  menus, menu-navigation
Side Menu.ios
Animated side menu with customizable UI
Stars: ✭ 2,702 (+10708%)
Mutual labels:  menubar, menu-navigation
CodeIgniter-Adjacency-List
Simple implementation with nestedSortable plugin.
Stars: ✭ 18 (-28%)
Mutual labels:  menu-generator, menu-navigation
ContextMenuSwift
A better version of iOS 13 Context Menu
Stars: ✭ 162 (+548%)
Mutual labels:  menubar, menus
umi-plugin-menus
将 umi 生成的 routes 转换成 tree 结构 menus 数据,开发中可直接引入该文件来进行导航菜单的生成
Stars: ✭ 29 (+16%)
Mutual labels:  menus
casita
A macOS menubar app to control media playing on your Google Cast enabled devices. 🏡
Stars: ✭ 22 (-12%)
Mutual labels:  menubar
pi-top-setup
Using Raspbian Buster and Raspbian Stretch on the pi-top
Stars: ✭ 45 (+80%)
Mutual labels:  menu-item
weibotuchuang-electron
围脖是个好图床
Stars: ✭ 31 (+24%)
Mutual labels:  menubar
Lyricsx
🎶 Ultimate lyrics app for macOS.
Stars: ✭ 3,251 (+12904%)
Mutual labels:  menubar
react-push-menu
react multi level push menu
Stars: ✭ 37 (+48%)
Mutual labels:  menus
oc-menumanager-plugin
A Menu Management Plugin for October CMS
Stars: ✭ 29 (+16%)
Mutual labels:  menu-navigation
macOSAppsOpenSource
No description or website provided.
Stars: ✭ 33 (+32%)
Mutual labels:  menubar
curved-menu
VanillaJS fully configurable curved menu (circular navigation)
Stars: ✭ 30 (+20%)
Mutual labels:  menu-navigation
DisplayMenu
A simple (bare-bones) macOS menubar extra to apply display presets.
Stars: ✭ 42 (+68%)
Mutual labels:  menubar
gifbar
🦄 Find Awesome Gif's right in your Menu Bar
Stars: ✭ 37 (+48%)
Mutual labels:  menubar
menutray
An application menu through a GTK+ tray status icon.
Stars: ✭ 62 (+148%)
Mutual labels:  menu-generator
hipsbarjs
Hipsbarjs is a javascript plugin for easily creating drawers in web apps
Stars: ✭ 17 (-32%)
Mutual labels:  menu-navigation
bunch
Documentation repository for Bunch.app
Stars: ✭ 74 (+196%)
Mutual labels:  menubar

PHP Quick Menu

Esta clase PHP permite crear un menu Html a partir de una string Json. Por favor califica este repositorio, pues de esa forma voy a saber que este trabajo está siendo útil. La clase tiene parámetros de configuración, explicados en este tutorial: http://codeignitertutoriales.com/php-menu-dinamico-multinivel/

Yes

Input

[{
	"text": "Home",
	"href": "#home",
	"title": "Home"
}, {
	"text": "About",
	"href": "#",
	"title": "About",
	"children": [{
		"text": "Action",
		"href": "#action",
		"title": "Action"
	}, {
		"text": "Another action",
		"href": "#another",
		"title": "Another action"
	}]
}, {
	"text": "Something else here",
	"href": "#something",
	"title": "Something else here"
}]

Output

<ul class="nav navbar-nav" id="#myMenu">
   <li><a href="#home" title="Home">Home</a></li>
   <li class="dropdown">
      <a href="#" title="About" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About <i class="caret"></i></a>
      <ul class="dropdown-menu">
         <li><a href="#action" title="Action">Action</a></li>
         <li><a href="#another" title="Another action">Another action</a></li>
      </ul>
   </li>
   <li><a href="#something" title="Something else here">Something else here</a></li>
</ul>

How to use

  • Extend the QuickMenu class for customization. For instance Bootstrap menu. (This is optional)
require 'QuickMenu.php';
class BootstrapMenu extends QuickMenu
{
    public function __construct($options = array())
    {
        parent::__construct($options);
        $this->setDropDownIcon('<i class="caret"></i>');
        $this->set('ul-root', array('class'=>'nav navbar-nav', 'id'=>'#myMenu'));
        $this->set('ul', array('class'=>'dropdown-menu'));
        $this->set('li-parent', array('class'=>'dropdown'));
        $this->set('a-parent', array('class'=>"dropdown-toggle", 'data-toggle'=>"dropdown", 'role'=>"button", 'aria-haspopup'=>"true", 'aria-expanded'=>"false"));
    }
}
  • Include your class
include "BootstrapMenu.php";
$str = '[{"text":"Home", "href": "#home", "title": "Home"}, {"text":"About", "href": "#", "title": "About", "children": [{"text":"Action", "href": "#action", "title": "Action"}, {"text":"Another action", "href": "#another", "title": "Another action"}]}, {"text":"Something else here", "href": "#something", "title": "Something else here"}]';
  • Instance the class with data parameters
$qMenu = new BootstrapMenu(array('data'=>$str));
  • Use the methods availables
$qMenu->setActiveItem('http://codeignitertutoriales.com');
$qMenu->insert(array("text"=>'Ooh!', "href"=>'http://codeignitertutoriales.com', "title"=>'Awesome'), 'Another action', 'About');
$qMenu->insert(array("text"=>'Ultimo item', "href"=>'https://github.com/davicotico', "title"=>'My Github'));
  • Renderize the menu in a string variable
$menu = $qMenu->html();
  • Done. You can echoes the menu on html document
<div id="navbar" class="navbar-collapse collapse">
    <?php echo $menu ?>
</div>

Class reference

setActiveItem($href, $activeClass = '')

Setting the active item.

Parameters:

  • string $href The active href
  • string $activeClass (Optional) The Css class for the active item

insert($item, $before_at = '', $parent = '')

Insert an item

Parameters:

  • array $item - Associative array with item attributes (text, href, icon, title)
  • string $before_at (Optional) The reference position for insert
  • string $parent (Optional) The parent if the insert is in submenu

remove($text)

Remove an item (from top level) by text attribute

Parameters:

  • string $text Text item

replace(array $newItem, $text)

Replace an item (find by text attribute)

Parameters:

  • array $newItem The new item
  • string $text The text item for search

html()

The Html menu

return: string Html menu

setData($data)

Setting the data from json string or associative array

Parameters:

  • mixed $data Data (Json string or associative array)

setResult($result, $columnID, $columnParent)

Set result from query database

Parameters:

  • array $result The resultset
  • string $columnID The ID column name (Primary key)
  • string $columnParent The column name for identify the parent item

setDropdownIcon($content)

Set dropdown icon for display with submenus

Parameters:

  • string $content Content for the dropdown icon (Html code)

set($name, $value)

Set the attributes for the tag vars

Parameters:

  • string $name Var name
  • mixed $value Var value

Var names: 'ul', 'ul-root', 'li', 'li-parent', 'a', 'a-parent', 'active-class'

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].