You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 437 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Treemenu block

17.2.2. Treemenu block

A commonly asked question in PHPNuke forums (see for example Menu Hack Needed (show different menu or block depending on the category)), is if there exists some Module block out there that displays a dynamic view of the available modules. The webmaster needs a functionality that will allow for the display of only certain module links, depending on, say, the interests, access level, or preferences of the viewer.

A typical Module block, as shipped with the standard PHPNuke package, looks as in Figure 17-2.

Figure 17-2. The standard Modules block.

The standard Modules block.



What we need instead is a module block that displays some links (to modules, or generally, to pages) when a certain condition is met (say, when Category A was previously chosen) and some other ones when a different condition is true (e.g. when Category B was chosen).

17.2.2.1. The general idea

To met the above requirements, the Treemenu block for PHP-Nuke adapts the well-known Treemenu concept to a PHPNuke Block and creates a PHPNuke block containing a Treemenu which looks as in Figure 17-3.

Figure 17-3. Treemenu Block.

Treemenu Block.



When the user clicks on an item like "Links", the subtree under this item is unfolded (Figure 17-4).

Figure 17-4. Treemenu Block with "Links" expanded.

Treemenu Block with "Links" expanded.



A further click on the subcategory "My work" will reveal another level of groups (Figure 17-5).

Figure 17-5. Treemenu Block with "My work" expanded.

Treemenu Block with "My work" expanded.



Finally, a click on a subsubcategory like "Linux" will unfold the "leaves" of the Treemenu (Figure 17-6).

Figure 17-6. Treemenu Block with "Linux" expanded.

Treemenu Block with "Linux" expanded.



Of course, the naming and nesting of categories and/or items is fully arbitrary. The above functionality can easily be adapted to suit more advanced needs too (see refinements of the PHP-Nuke Treemenu).

17.2.2.2. What is Treemenu

The Treemenu block makes use of a Treemenu in a PHPNuke Block. Treemenu is a PHP class created by Bjorge Dijkstra (original script to be found Treemenu Class from Bjorge) and adapted by Denny Shimkoski (his version to be found in Treemenu from Denny). Chris have fixed some bugs in the latter one and integrated it into a Treemenu block for PHP-Nuke.

There are two ways you can use the Treemenu class - Chris uses the one that takes as input a simple text file and creates a tree menu, in a style that most users are familiar with from a graphical file manager (see Figure 17-3). Navigation through such a tree is done intuitively by expanding and collapsing the various tree levels by clicking on the node icons (the icons are discussed in custom node icons for the PHP-Nuke Treemenu).

To create a Treemenu, once you have written the input text file with your favorite text editor (see input file method for the Treemenu) or used the alternative method to fill the nodes and leaves of the Treemenu, you just have to write this 3-liner to get it up and running:

include("blocks/treemenu/treemenu.inc");
$tree = new TreeMenu("a", "blocks/treemenu/sitemap.txt");
$tree->show();
Note Note
 

In order to be able to display the output of the above code in a PHPNuke Block, we have to capture it in an output buffer with the ob_start(), ob_get_contents() and ob_end_clean() mechanism:

ob_start();
include("blocks/treemenu/treemenu.inc");
$tree = new TreeMenu("a", "blocks/treemenu/sitemap.txt");
$tree->show();
$output = ob_get_contents();
ob_end_clean();
$content = $output;


See Treemenu block for PHP-Nuke for more information of how to use the Treemenu block as a module block for PHP-Nuke.


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.094 Seconds - 177 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::