The Axis have taken control over large portions of the Russian city of Stalingrad. In order to <br /> re-take the city, the Allies must gain control of a small neighborhood on the western side of <
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).
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).
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).
include("blocks/treemenu/treemenu.inc");
$tree = new TreeMenu("a", "blocks/treemenu/sitemap.txt");
$tree->show();
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: