Page 5 of 10
Posted: Wed 15. Mar 2006, 22:53
by hendrik
rtilghman wrote:
What I would like to do is have the ability to have the parent item "active" when a child area is selected... which would make a lot more sense. So, for example, if you had a menu with 5 top links (visible) andthe user was in a page that resides in the pathway of "link 1" link 1 would have the ACTIVE class so you could have it highlighted.
I found something that works concerning your idea. can be improved though. I'm a php beginner. yippi.
Code: Select all
<?php
function build_dhtmlmenu2($start=0, $class='', $activeclass='', $counter=0) {
// **************************************************************************
// Paul: nice HTML source format, from class='classname' to class="classname"
$class="class="".$class.""";
$classactive="class="".$activeclass.""";
// Paul: nice HTML source format END
// **************************************************************************
$s = '';
$g = '';
// **************************************************************************
// Paul: for submenu
$thfs = $GLOBALS["content"]["struct"];
foreach($thfs as $key => $value)
{
$x = &$GLOBALS["content"]["struct"][$value["acat_struct"]];
if($value["acat_struct"] != 0)
$x["acat_has_children"] = 1;
else
$x["acat_has_children"] = 0;
}
// Paul: for submenu END
// **************************************************************************
// **************************************************************************
// Hendrik: 3 level
$bef0 = $GLOBALS['aktion'][0];
$bef1 = $GLOBALS['content']['struct'][$bef0]['acat_struct'];
$bef2 = $GLOBALS['content']['struct'][$bef1]['acat_struct'];
// Hendrik: 3 level END
// **************************************************************************
foreach($GLOBALS['content']['struct'] as $key => $value) {
if ($start == $GLOBALS['content']['struct'][$key]['acat_struct'] &&
!$GLOBALS['content']['struct'][$key]['acat_hidden'] && $key)
{
$s .= '<li';
// **************************************************************************
// Hendrik: change and add
if($key == $bef0 && $activeclass) $s .= ' '.$classactive;
if($key == $bef1 && $activeclass) $s .= ' '.$classactive;
if($key == $bef2 && $activeclass) $s .= ' '.$classactive;
// Hendrik: change and add END
// **************************************************************************
$s .= '>';
if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) {
$s .= '<a href="index.php?';
if($GLOBALS['content']['struct'][$key]['acat_alias']) {
$s .= $GLOBALS['content']['struct'][$key]['acat_alias'];
} else {
$s .= 'id='.$key.',0,0,1,0,0';
}
// **************************************************************************
// Paul: change and add
$s .= '"';
if($GLOBALS['content']['struct'][$key]['acat_has_children'])
$s .= ' class="submenu"';
$s .= '>';
// Paul: change and add END
// **************************************************************************
} else {
$redirect = get_redirect_link($GLOBALS['content']['struct'][$key]["acat_redirect"], ' ', '');
$s .= '<a href="'.$redirect['link'].'"'.$redirect['target'].'>';
}
$s .= html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']);
$s .= '</a>';
$s .= build_dhtmlmenu2($key, $class, $activeclass,$counter+1);
$s .= "</li>\n";
}
}
if($s) {
$g = "\n<ul";
if(!$counter && $class) {
$g .= ' '.$class;
}
$g .= ">\n".$s.'</ul>';
}
return $g;
}
// parse the whole webpage $content["all"] is the fully rendered webpage your site displays
$content["all"] = (myTagParser ($content["all"]));
// parse the $string and replace all possible instances of the following {RT}'s
function myTagParser($string) {
$search[0] = '/\{DHTMLMENU:(.*?),(.*?),(.*?)\}/e';
$replace[0] = 'build_dhtmlmenu2("$1","$2","$3");';
$string = preg_replace($search, $replace, $string);
$string = str_replace('\'', '\'',$string);
$string = str_replace('"', '"',$string);
return $string; // spit out the final webpage for display
}
?>
Posted: Fri 17. Mar 2006, 01:02
by hendrik
ok, no one is impressed so I improved the code a bit:
you can have a look at
http://www.hendrikschirmann.de/cms
well, site is under construction
the code gives a css class to the item you clicked on and the 'itemOn'-class to
the parents and it checks all levels of parents automaticly.
Code: Select all
<?php
function build_dhtmlmenu2($start=0, $class='', $activeclass='', $counter=0) {
// **************************************************************************
// Paul: nice HTML source format, from class='classname' to class="classname"
$class="class=\"".$class."\"";
$classactive="class=\"".$activeclass."\"";
// Paul: nice HTML source format END
// **************************************************************************
$s = '';
$g = '';
// **************************************************************************
// Paul: for submenu
$thfs = $GLOBALS["content"]["struct"];
foreach($thfs as $key => $value)
{
$x = &$GLOBALS["content"]["struct"][$value["acat_struct"]];
if($value["acat_struct"] != 0)
$x["acat_has_children"] = 1;
else
$x["acat_has_children"] = 0;
}
// Paul: for submenu END
// **************************************************************************
// Hendrik: add
$bef[0] = $GLOBALS['aktion'][0];// the ID of the item you clicked is stored
$se = 0;
while ($bef[$se])//if there are parents, this is > 0
{
$se++;
$bef[$se] = $GLOBALS['content']['struct'][$bef[$se-1]]['acat_struct'];// store parents ID's
}
// Hendrik: add END
// **************************************************************************
foreach($GLOBALS['content']['struct'] as $key => $value) {
if ($start == $GLOBALS['content']['struct'][$key]['acat_struct'] &&
!$GLOBALS['content']['struct'][$key]['acat_hidden'] && $key)
{
$s .= '<li';
// **************************************************************************
// Hendrik: change and add
if ($activeclass)
{
for ($i = 0 ; $i <= $se ; $i++)
{
if($key == $bef[$i])
{
if (!$i) $s .= ' class="itemChoosen"'; //the choosen item can get an extra css-class
else $s .= ' '.$classactive; //parents
}
}
}
// Hendrik: change and add END
// **************************************************************************
$s .= '>';
if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) {
$s .= '<a href="index.php?';
if($GLOBALS['content']['struct'][$key]['acat_alias']) {
$s .= $GLOBALS['content']['struct'][$key]['acat_alias'];
} else {
$s .= 'id='.$key.',0,0,1,0,0';
}
// **************************************************************************
// Paul: change and add
$s .= '"';
if($GLOBALS['content']['struct'][$key]['acat_has_children'])
$s .= ' class="submenu"';
$s .= '>';
// Paul: change and add END
// **************************************************************************
} else {
$redirect = get_redirect_link($GLOBALS['content']['struct'][$key]["acat_redirect"], ' ', '');
$s .= '<a href="'.$redirect['link'].'"'.$redirect['target'].'>';
}
$s .= html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']);
$s .= '</a>';
$s .= build_dhtmlmenu2($key, $class, $activeclass,$counter+1);
$s .= "</li>\n";
}
}
if($s) {
$g = "\n<ul";
if(!$counter && $class) $g .= ' '.$class;
$g .= ">\n".$s.'</ul>';
}
return $g;
}
// parse the whole webpage $content["all"] is the fully rendered webpage your site displays
$content["all"] = (myTagParser ($content["all"]));
// parse the $string and replace all possible instances of the following {RT}'s
function myTagParser($string) {
$search[0] = '/\{DHTMLMENU:(.*?),(.*?),(.*?)\}/e';
$replace[0] = 'build_dhtmlmenu2("$1","$2","$3");';
$string = preg_replace($search, $replace, $string);
$string = str_replace('\'', '\'',$string);
$string = str_replace('"', '"',$string);
return $string; // spit out the final webpage for display
}
?>
hendrik
Posted: Fri 17. Mar 2006, 01:08
by Kosse
hendrik wrote:ok, no one is impressed so I improved the code a bit:
you can have a look at
http://www.hendrikschirmann.de/cms
well, site is under construction
the code gives a css class to the item you clicked on and the 'itemOn'-class to
the parents and it checks all levels of parents automaticly.
hendrik
It looks very cool hendrik, thx for sharing!
Cheers
Posted: Fri 17. Mar 2006, 01:31
by hendrik
thank you Kosse!

Posted: Fri 17. Mar 2006, 09:45
by Paal
Kosse wrote:hendrik wrote:ok, no one is impressed so I improved the code a bit:
you can have a look at
http://www.hendrikschirmann.de/cms
well, site is under construction
the code gives a css class to the item you clicked on and the 'itemOn'-class to
the parents and it checks all levels of parents automaticly.
hendrik
It looks very cool hendrik, thx for sharing!
Cheers
Great job!
Paul
Posted: Fri 17. Mar 2006, 17:24
by hendrik
thanx Paal, nice to hear!
Posted: Tue 21. Mar 2006, 12:46
by hendrik
want some more classes (and work and confusion

)?
then exchange
Code: Select all
// Hendrik: change and add
if ($activeclass)
{
for ($i = 0 ; $i <= $se ; $i++)
{
if($key == $bef[$i])
{
if (!$i) $s .= ' class="itemChoosen"'; //the choosen item can get an extra css-class
else $s .= ' '.$classactive; //parents
}
}
}
// Hendrik: change and add END
by
Code: Select all
// Hendrik: change and add
if ($activeclass)
{
for ($i = 0 ; $i <= $se ; $i++)
{
if($key == $bef[$i])
{
if (!$i)
{
if ($se == 1) $s .= ' class="itemChoosenFirst"';//item choosen no parents (is upmost level)
else $s .= ' class="itemChoosen"'; //item choosen has parents
}
else
{
if ($se == $i +1) $s .= ' class="itemOnFirst"'; //upmost level leading to item choosen
else $s .= ' '.$classactive; //class="itemOn" leading to item choosen
}
}
}
}
// Hendrik: change and add END
could look like:
hendrik
Posted: Fri 24. Mar 2006, 09:30
by Heiko H.
Hallo,
super RT !!!
Does anybody have an idea how to delay the menu collapse 1-2 seconds?
Once the mouse is outside the menu, the menu collapse immediately, so the user has to start the navigation again.
THX!
Posted: Sat 13. May 2006, 05:15
by Stim
Hi
Is it more then one menu in this topic?
Can someone please post all file I for this menu somewhere because I don’t really understand how to fix this stuff
There are lots off cod in this topic and don’t really know if all cod is for different menu or just for one menu.

Posted: Mon 15. May 2006, 10:28
by ssyfrig
Hi Stim
check
http://www.swisscopter.net/index.php?cms
I create a zip file for you, with all files (code) where I running on swisscopter.net
greez Sven
Posted: Mon 15. May 2006, 19:22
by Stim
Hi
Thanks for zip file
Is this menu based on the category structure in admin or can I add and remove link in the menu?
I need menu that lets my choose my one category, subcategory or link to other pages in the menu etc. Can I do that whiteout "hide and sows category" in admin?
Posted: Fri 19. May 2006, 11:52
by Stim
Hi again
There is one file ”DHTMLMENU2.php” in that zip file. which folder do I insert the file in phpwcms?
Someone?
Posted: Fri 19. May 2006, 11:56
by ssyfrig
/phpwcms_template/inc_script/frontend_render/
greez Sven
Posted: Tue 30. May 2006, 00:46
by Stim
I need menu that lets my choose my one category, subcategory or link to other pages in the menu etc. Can I do that whiteout "hide and sows category" in admin?[/quote]
Bump!!
Posted: Tue 30. May 2006, 02:01
by pepe
Look into ADMIN... there you can make a redirection to
another page of your site... or to a
page of another site 