Class HtmlNavbar
Copyright:
2004-2016 The Admidio Team
License:
GNU General Public License v2.0 only
**********************************************************************************************
Brief:
Class manages display of navbar in modules
This class manage the presentation of a module menu. You can add as many
items to the menu and the class tries to display them in the perfect
way for the module. If there are to many items to display all than it
will create a menu button where you can find all the other menu items.
The position of the items is important. Only the first items will display
permanently in the module. The other items are summarized in a submenu.
Class:
HtmlNavbar
Code:
// create module menu
$myNavbar = new HtmlNavbar('menu_my_module', 'My module');
// show link to create new announcement
$myNavbar->addItem('menu_item_new_entry', $g_root_path.'/adm_program/modules/mymodule/mymodule_new.php',
$gL10n->get('SYS_CREATE'), 'add.png');
$myNavbar->show(); @endcode
Par:
Examples
Located at htmlnavbar.php
Methods summary
public
|
#
__construct( string $id, string $name = null, HtmlPage $htmlPage = null, string $type = 'default' )
creates the object of the module menu and initialize all class parameters
creates the object of the module menu and initialize all class parameters
Parameters
- $id
- Html id of the navbar
- $name
- Name of the navbar that will be shown when navbar changed to vertical mode on small devices
- $htmlPage
Optional a HtmlPage object that will be used to add javascript code
or files to the html output page.
- $type
Different types of the navbar can be defined.
default: will be the standard navbar of all modules.
filter: should be used if this navbar is used to filter data of within the script.
|
protected
string
|
#
createHtmlLink( array $data )
Creates the html for the menu entry.
Creates the html for the menu entry.
Parameters
- $data
- An array with all data if the item. This will be @id, @url, @text and @icon.
Returns
string Returns the html for the menu entry
|
public
|
#
addCssClass( string $className )
This method adds an additional css class to the main nav tag of the menu.
This method adds an additional css class to the main nav tag of the menu.
Parameters
- $className
- The name of a css class that should be add to the main nav tag of the manu
|
public
|
#
addForm( string $htmlForm )
Add a form to the menu. The form will be added between the left and the right part of the navbar.
Add a form to the menu. The form will be added between the left and the right part of the navbar.
Parameters
- $htmlForm
- A html code of a form that will be added to the menu
|
public
|
#
addItem( string $id, string $url, string $text, string $icon, string $orientation = 'left', string $parentItem = 'navbar', string $class = '' )
Add a new item to the menu. This can be added to the left or right part of the navbar.
You can also add another item to an existing dropdown item. Therefore use the @b $parentItem parameter.
Add a new item to the menu. This can be added to the left or right part of the navbar.
You can also add another item to an existing dropdown item. Therefore use the @b $parentItem parameter.
Parameters
- $id
- Html id of the item.
- $url
- The url of the generated link of this item.
- $text
- The text of the item and the generated link.
- $icon
- Icon of the menu item, that will also be linked
- $orientation
- The item can be shown at the @b left or @b right part of the navbar.
- $parentItem
All items should be added to the @b navbar as parent. But if you
have already added a dropdown than you can add the item to that
dropdown. Just commit the id of that item.
- $class
- Optional a css class that will be set for the item.
|
public
|
#
setName( string $name )
Set the name of the navbar that will be shown when navbar changed to vertical mode on small devices.
Set the name of the navbar that will be shown when navbar changed to vertical mode on small devices.
Parameters
- $name
- New name of the navbar.
|
private
string
|
#
getNavHtml( array[] $items, string $class = '' )
Parameters
Returns
string
|
public
string
|
#
show( )
Creates the html output of the module menu. Each added menu item will be displayed.
If one item has several subitems than a dropdown button will be created.
Creates the html output of the module menu. Each added menu item will be displayed.
If one item has several subitems than a dropdown button will be created.
Returns
string Returns the html output for the complete menu
|