fi.protie.navigation
fi.protie.navigation is a library for drawing most of the cases needed for navigation. It uses class midcom.helper.nav to parse the path.
Usage
Here is an example of how to use fi.protie.navigation:
<?php
// Loads the component for the first time
$_MIDCOM->componentloader->load('fi.protie.navigation');
// Initializes the class
$navigation = new fi_protie_navigation();
// Display only nodes (folders)
$navigation->list_leaves = false;
// Expand the whole site tree instead of the active path
$navigation->follow_all = true;
// Skip 1 level from the beginning of the active path
$navigation->skip_levels = 1;
// Finally draw the navigation
$navigation->draw();
?>
Public properties
Navigating the site structure
root_id(integer)- ID for the folder to get the navigation. On default the navigation will start from the root folder.
skip_levels(integer)- The amount of lowest level elements to be skipped. On default no levels are skipped.
list_leaves(boolean)- Switch to determine if navigation should display leaves or pages. Default is
true
- Switch to determine if navigation should display leaves or pages. Default is
list_nodes(boolean)- List only the leaf elements or pages. Default is
false
- List only the leaf elements or pages. Default is
follow_selected(boolean)- Switch to determine if navigation should follow node path (on true) or stop on the spot. Default is
true.
- Switch to determine if navigation should follow node path (on true) or stop on the spot. Default is
follow_all(boolean)- Switch to determine if navigation should follow all the nodes or only the current Default is
false.
- Switch to determine if navigation should follow all the nodes or only the current Default is
show_only_current(boolean)- Switch to determine if navigation should show only the information of the currently selected node. Default is
false.
- Switch to determine if navigation should show only the information of the currently selected node. Default is
list_levels(integer)- Numeric depth of the navigation. Set this to prevent any navigation level from going too deep. If no restricting is required, use
0(default).
- Numeric depth of the navigation. Set this to prevent any navigation level from going too deep. If no restricting is required, use
CSS class availability
url_name_to_class(boolean)- Add URL name to list item class name. Default is
false.
- Add URL name to list item class name. Default is
component_name_to_class(boolean)- Add component name to list item ul class name. Default is
false.
- Add component name to list item ul class name. Default is
CSS styles
css_list_style(string)- CSS class for styling the lists. This will be the class of
ulelement. Default isfi_protie_navigation.
- CSS class for styling the lists. This will be the class of
css_node(string).- CSS class for nodes. Default is
node.
- CSS class for nodes. Default is
css_leaf(string)- CSS class for leaves. Default is
leaf.
- CSS class for leaves. Default is
css_selected(string)- CSS class for the elements in node path. All the elements in node path will have this class. Default is
selected.
- CSS class for the elements in node path. All the elements in node path will have this class. Default is
css_active(string)- CSS class for the current, active node or leaf. There can be only one active element. Default is
active.
- CSS class for the current, active node or leaf. There can be only one active element. Default is
Public methods
public css_dropdown_headers()
To activate CSS based dropdown menu proper CSS stylesheets should be loaded with the component. Therefore one should call out for method css_dropdown_headers() to include the link. This has to be done before calling for $_MIDCOM->print_head_elements();.
<?php
// Loads the component for the first time
$_MIDCOM->componentloader->load('fi.protie.navigation');
// Initializes the class
$navigation = new fi_protie_navigation();
$navigation->css_dropdown_headers();
?>
This will also set the property follow_all to true.
Notes
By default the CSS file navigation.css will be creating a dropdown list of any unordered list inside #navigation element.
fi.protie.navigation has also a version of Peter Nederlof's csshover.htc, which emulates :hover selector for any HTML element on Microsoft Internet Explorer 6.
This file will not be included automatically to the HTML, but it will be included in the package for web developers.
To use the behavior file include this to the head element.
<!--[if lte IE 6]>
body
{
behavior: url('<?php echo MIDCOM_STATIC_URL; ?>/fi.protie.navigation/csshover.htc');
}
<![endif]-->
public draw()
Method draw() draws the navigation as requested.
<?php
$navigation->draw();
// Results like this
?>
<ul class="fi_protie_navigation node-504">
<li class="selected active">
<a href="http://www.example.net/legacy.html">Legacy</a>
</li>
<li>
<a href="http://www.example.net/scores/">Scores</a>
<ul class="fi_protie_navigation node-506">
<li>
<a href="http://www.example.net/scores/team/e996dcf43bbbf20484011e5c8ade12cc/">Skull cap</a>
</li>
<li>
<a href="http://www.example.net/scores/events/">Events</a>
</li>
</ul>
</li>
</ul>
public static get_node_path()
Static method get_node_path parses all the visible active nodes (folders) and the possible current active leaf (page) and returns an array containing a list of the used IDs.
First item (array key 0) is the root folder of the web site and last will be the currently active page or folder.
<?php
$node_path = fi_protie_navigation::get_node_path();
print_r($node_path);
// Results:
// Array
// (
// [0] => 504
// [1] => 508
// [2] => 509
// [3] => 509-2572
// )
?>
