Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Paal
Posts: 204 Joined: Wed 6. Oct 2004, 19:54
Location: Budapest, Hungary
Contact:
Post
by Paal » Sun 27. Feb 2005, 12:06
Hello,
I use
{DROPDOWN} tag but I need the point of the menu, when "if menu has children" (I sould sign those points whom have submenus).
As I know,
function build_dhtmlmenu creates it in include/inc_front/front.func.inc.php file (around 2498 lines). Unforunately Brans can not help me
brans wrote: The first thing I did is the following:
every <ul> now has the id=nav added. Try to find the code for "if menu has children",
I know that there exists some function by OG but I don't remember where.
What I need (+ name="" class=""):
Code: Select all
<ul id=nav>
<li><a href="#" name="submenu" class="submenu">Menu 1</a>
<ul>
<li><a href="#">Menu 1,1</a></li>
<li><a href="#" name="submenu" class="submenu">Menu 1,2</a>
<ul>
<li><a href="#">Menu 1,2,1</a></li>
<li><a href="#">Menu 1,2,2</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Menu 2</a></li>
<li><a href="#">Menu 3</a></li>
<li><a href="#">Menu 4</a></li>
</ul>
Thx, Paul
Last edited by
Paal on Mon 28. Feb 2005, 14:08, edited 1 time in total.
Paal
Posts: 204 Joined: Wed 6. Oct 2004, 19:54
Location: Budapest, Hungary
Contact:
Post
by Paal » Mon 28. Feb 2005, 14:06
Paal wrote: Hello,
I use
{DROPDOWN} tag but I need the point of the menu, when "if menu has children" (I sould sign those points whom have submenus).
As I know,
function build_dhtmlmenu creates it in include/inc_front/front.func.inc.php file (around 2498 lines). Unforunately Brans can not help me
brans wrote: The first thing I did is the following:
every <ul> now has the id=nav added. Try to find the code for "if menu has children",
I know that there exists some function by OG but I don't remember where.
What I need (+ name="" class=""):
Code: Select all
<ul id=nav>
<li><a href="#" name="submenu" class="submenu">Menu 1</a>
<ul>
<li><a href="#">Menu 1,1</a></li>
<li><a href="#" name="submenu" class="submenu">Menu 1,2</a>
<ul>
<li><a href="#">Menu 1,2,1</a></li>
<li><a href="#">Menu 1,2,2</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Menu 2</a></li>
<li><a href="#">Menu 3</a></li>
<li><a href="#">Menu 4</a></li>
</ul>
Thx, Paul
The result (function build_dhtmlmenu in include/inc_front/front.func.inc.php):
OLD:
Code: Select all
function build_dhtmlmenu($start=0, $class='', $activeclass='', $counter=0) {
// builds a <ul><li> list based on structure
// layout settings for $class = array(
// 'count' => 0 (if the depth should be added to class/id name)
// 'every' => 0 (if set 1 every sub-<ul> will get the class/id name
// 'ul_i' => 'mydhtmlid'
// 'ul_c' => 'mydhtmlclass'
// 'ul_ia' => 'mydhtmlactiveid'
// 'ul_c' => 'mydhtmlactiveclass'
// 'li_ca' => 'myactiveclass' (for setting different class for active <li>)
$s = '';
$g = '';
foreach($GLOBALS['content']['struct'] as $key => $value) {
if ($start == $GLOBALS['content']['struct'][$key]['acat_struct'] &&
!$GLOBALS['content']['struct'][$key]['acat_hidden'] && $key)
{
$s .= '<li';
if($key == $GLOBALS['aktion'][0] && $activeclass) $s .= ' '.$activeclass;
$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';
}
$s .= '">';
} 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_dhtmlmenu($key, $class, $counter+1);
$s .= "</li>\n";
}
}
if($s) {
$g = "\n<ul";
if(!$counter && $class) $g .= ' '.$class;
$g .= ">\n".$s.'</ul>';
}
return $g;
}
New:
Code: Select all
function build_dhtmlmenu($start=0, $class='', $activeclass='', $counter=0) {
// builds a <ul><li> list based on structure
// layout settings for $class = array(
// 'count' => 0 (if the depth should be added to class/id name)
// 'every' => 0 (if set 1 every sub-<ul> will get the class/id name
// 'ul_i' => 'mydhtmlid'
// 'ul_c' => 'mydhtmlclass'
// 'ul_ia' => 'mydhtmlactiveid'
// 'ul_c' => 'mydhtmlactiveclass'
// 'li_ca' => 'myactiveclass' (for setting different class for active <li>)
$s = '';
$g = '';
$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;
}
# echo("<pre>\n");
# print_r($GLOBALS['content']['struct']);
# echo("</pre>\n");
foreach($GLOBALS['content']['struct'] as $key => $value) {
if ($start == $GLOBALS['content']['struct'][$key]['acat_struct'] &&
!$GLOBALS['content']['struct'][$key]['acat_hidden'] && $key)
{
$s .= '<li';
if($key == $GLOBALS['aktion'][0] && $activeclass) $s .= ' '.$activeclass;
$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';
}
$s .= '"';
if($GLOBALS['content']['struct'][$key]['acat_has_children'])
$s .= ' class="submenu" name="submenu"';
$s .= '>';
} 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_dhtmlmenu($key, $class, $counter+1);
$s .= "</li>\n";
}
}
if($s) {
$g = "\n<ul";
if(!$counter && $class) $g .= ' '.$class;
$g .= ">\n".$s.'</ul>';
}
return $g;
}
Bye, Paul