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

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

Read and follow the rules, otherwise your posts will be closed
· Home
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 263 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). 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). 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:

$tree = new TreeMenu("a", "blocks/treemenu/sitemap.txt");
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:

$tree = new TreeMenu("a", "blocks/treemenu/sitemap.txt");
$output = ob_get_contents();
$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

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.157 Seconds - 384 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded ( ::