|
|
| Author |
Message |
Pasteur Private

Joined: 14 Oct 2004 Posts: 4
|
Posted: Thu Oct 14, 2004 12:41 pm Post subject: Treemenu as a PHP-Nuke module |
|
|
|
I'm using the Treemenu block and am delighted!
However, I would like to use it as a module rather than a block so that the fully expanded Treemenu could be called from a "Site Map" link and displayed like a module on its own in the central part of the page.
Is there a simple way to convert the Treemenu block to a Treemenu module?
Thank you in advance for your help.
Olivier Pasteur |
|
| Back to top |
|
 |
chris Dark Lord of the Sith

Joined: 10 May 2003 Posts: 6262 Location: Outer Space
|
Posted: Thu Oct 14, 2004 3:03 pm Post subject: |
|
|
|
See How to convert a PHP-Nuke block into a PHP-Nuke module. I hope this thread will help you create a module from the Treemenu block.
Don't forget to come back and report what you did when you are finished.
And of course feel free to ask if you get stuck along the way. _________________ Regards
Chris Karakas
www.karakas-online.de |
|
| Back to top |
|
 |
Pasteur Private

Joined: 14 Oct 2004 Posts: 4
|
Posted: Thu Oct 14, 2004 8:01 pm Post subject: |
|
|
|
Thanks for the hint, it works like a charm! I have also added multilingual features with the switch() alternative method:
| Code: | global $currentlang; // get the current language
$newlang = "$currentlang"; // assign current language to variable
switch ($newlang) {
case english:
$tree = new TreeMenu("a", "blocks/treemenu/sitemap_e.txt"); // text file in English
$tree->show();
break;
case french:
$tree = new TreeMenu("a", "blocks/treemenu/sitemap_f.txt"); // text file in French
$tree->show();
break;
case spanish:
$tree = new TreeMenu("a", "blocks/treemenu/sitemap_s.txt"); // text file in Spanish
$tree->show();
break;
default:
$tree = new TreeMenu("a", "blocks/treemenu/sitemap_e.txt"); // default text file (English)
$tree->show();
break;
} |
Cheers!
Olivier |
|
| Back to top |
|
 |
chris Dark Lord of the Sith

Joined: 10 May 2003 Posts: 6262 Location: Outer Space
|
Posted: Thu Oct 14, 2004 8:30 pm Post subject: |
|
|
|
Wow, thanks!
Can you please post the whole body of the module's index.php file? Just to have it for future reference here. _________________ Regards
Chris Karakas
www.karakas-online.de |
|
| Back to top |
|
 |
Pasteur Private

Joined: 14 Oct 2004 Posts: 4
|
Posted: Thu Oct 14, 2004 8:58 pm Post subject: |
|
|
|
Here is the content of the modified block-Treemenu.php (multilingual features) with the Treemenu module creation fully documented.
| Code: | <?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Treemenu Block */
/* ============== */
/* */
/* Copyright (c) 2002 by Chris Karakas <chris@karakas-online.de> */
/* http://karakas-online.de */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/* This PHPNuke 6.0 block will display a dynamic tree menu according */
/* to the entries found in the plain text file */
/* blocks/treemenu/sitemap.txt */
/* Edit this file to reflect your tree. As far as the syntax of it */
/* is concerned, you practically have to remember that a "." means */
/* "1st level entry", a ".." "2nd level" etc. The rest is just the */
/* text, the link and an optional window name for the link to */
/* appear in. See the file blocks/treemenu/treemenu.inc for more */
/* information and http://www.karakas-online.de/myTreemenu/t1.html */
/* for more documentation. */
/* */
/* Please mail me if you find any bugs and/or improvements. */
/* In the meantime, enjoy! */
/* */
/* Chris */
/* */
/************************************************************************/
/* */
/* Block mofified by Olivier Pasteur <webmaster@pasteur.net> */
/* Multilingual features added */
/* */
/************************************************************************/
/* This block can also work as a PhpNuke standard module
(Posted in NukeCops Forum and Chris Karakas Forum):
1) make a new directory modules/Treemenu
2) make a new file modules/Treemenu/index.php
3) fill the file with this code:
<?php
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
$module_name = basename(dirname(__FILE__));
$index = 0; # 0=don't show right side blocks, 1=show right side blocks
function treemenu() {
global $module_name;
include("header.php");
OpenTable();
echo "<center>$module_name</center>";
include("blocks/block-Treemenu.php");
echo $content;
CloseTable();
include("footer.php");
}
switch($func) {
default:
treemenu();
break;
}
?>
4) Link to the Treemenu module with the following URL:
http://www.mysite.com/modules.php?name=Treemenu&tmva=
or, if you want all branches expanded by default, use the relevant URL,
which should look something like this:
http://www.mysite.com/modules.php?name=Treemenu&tmva=1|2|3|4|..
/************************************************************************/
if (eregi("block-Treemenu.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
$blockfiletitle = ""._TSITEMAP.""; // Multilingual block title
ob_start();
include("blocks/treemenu/treemenu.inc");
/* load different Treemenus based on selected interface language */
global $currentlang; // get the current language
$newlang = "$currentlang"; // assign current language to variable
switch ($newlang) {
case english:
$tree = new TreeMenu("a", "blocks/treemenu/sitemap_e.txt"); // text file in English
$tree->show();
break;
case french:
$tree = new TreeMenu("a", "blocks/treemenu/sitemap_f.txt"); // text file in French
$tree->show();
break;
case spanish:
$tree = new TreeMenu("a", "blocks/treemenu/sitemap_s.txt"); // text file in Spanish
$tree->show();
break;
default:
$tree = new TreeMenu("a", "blocks/treemenu/sitemap_e.txt"); // default text file (English)
$tree->show();
break;
}
$output = ob_get_contents();
ob_end_clean();
$content = $output;
$content .= "" // Added a copyright window with credits to Chris Karakas and link to his homepage
?>
|
With all its branches expanded, the treemenu module looks like a well-structured site map, which was exactly what I was looking for
Hope it helps.
Olivier |
|
| Back to top |
|
 |
chris Dark Lord of the Sith

Joined: 10 May 2003 Posts: 6262 Location: Outer Space
|
Posted: Thu Oct 14, 2004 9:18 pm Post subject: |
|
|
|
Thank you very much Pasteur!  _________________ Regards
Chris Karakas
www.karakas-online.de |
|
| Back to top |
|
 |
occultbird Lance Corporal

Joined: 13 Mar 2007 Posts: 7
|
Posted: Fri Mar 16, 2007 3:16 am Post subject: Treemenu block to module - where to put the link |
|
|
|
Hello,
You've said:
4) Link to the Treemenu module with the following URL:
http://www.mysite.com/modules.php?name=Treemenu&tmva=
This just about where I got lost. Link from where to where and where at (which file)?
I'm a real phpnuke newbie,
Thanks
Raven _________________ Raven Crone |
|
| Back to top |
|
 |
Pasteur Private

Joined: 14 Oct 2004 Posts: 4
|
Posted: Sun Mar 18, 2007 5:04 pm Post subject: Re: Treemenu block to module - where to put the link |
|
|
|
Hi Raven,
Once you have installed, configured and tested your Treemenu block, you have to create the Treemenu module :
1) First create an empty file with the code below and name it 'index.php'
2) In your PhpNuke module folder, create a new folder called Treemenu
3) Copy the index.php file into that folder
4) In your PhpNuke Module Administration page, you will see the newly created module. Use the Treemenu module as any other module.
Modules\Treemenu\index.php :
| Code: |
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Treemenu Module */
/* =============== */
/* */
/* Based on Treemenu Block */
/* Copyright (c) 2002 by Chris Karakas <chris@karakas-online.de> */
/* http://karakas-online.de */
/* */
/* Module adapted by Olivier Pasteur <webmaster@pasteur.net> */
/* with multilingual features */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/************************************************************************/
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$index=2; // Remove left block
function treemenu() {
global $module_name;
include("header.php");
OpenTable();
echo "<center><font class=\"title\">"._SITEMAP."</font></center>";
CloseTable();
OpenTable();
include("blocks/block-Treemenu.php");
echo $content;
CloseTable();
include("footer.php");
}
switch($func) {
default:
treemenu();
break;
}
?> |
If you are not using multilingual features, remove the line "get_lang($module_name);" and replace "._SITEMAP." with a title of your choice.
If you are using multilingual features, you'll have to create a language folder into your Treemenu module folder with the relevant language files.
Best regards,
Olivier Pasteur |
|
| Back to top |
|
 |
|
|
 |
|
|