newbie140
-
Posts
7 -
Joined
-
Last visited
Posts posted by newbie140
-
-
Thank you very much Soma and drogo for your help..i've already modified the simpleNavigation module to display what i want....thanks more power...
Thanks again Soma, that's exactly what i did in the module...forgive me im weak in php...hehehe....thanks
-
Thank you very much Soma...but i only need to display the treemenu up to the 2nd level only at th homepage page...tnx
-
hi drogo..thanks for discussing with me...
Home About Media Bills & Resolutions Publications Projects Gallery Contact Us
thats what i want..even if i will go to "about" page or other page, the navigation structure will still looks the same...thanks
-
Thanks very much diogo...but it doesnt work the way i want it...my point is to include the "Home" menu together with other menus...thanks for your help
-
If it's still relevant. I took Apeisa's code from the above-mentioned topic and modified it a bit and it seems to work the way you wanded, Soma
<?php function treeMenu(Page $page = null, $depth = 1, $id = null) { $depth -= 1; if(is_null($page)) $page = wire('page'); if(!is_null($id)) $id = " id='$id'"; $out = "\n<ul$id>"; $parents = $page->parents; // This is where we get pages we want. You could just say template!=news-item foreach($page->children() as $child) { $class = "level-" . count($child->parents); $s = ''; if($child->numChildren && $depth > 0 ) { $s = str_replace("\n", "\n ", treeMenu($child, $depth)); } $class .= " page-{$child->id}"; $class = " class='$class'"; $out .= "\n <li$class>\n <a$class href='{$child->url}'>{$child->title}</a>$s\n </li>"; } $out .= "\n</ul>"; return $out; } //parameters: current page, menu depth, ul menu id $menu = treeMenu($page, 3, "myMenu"); echo $menu;
You shoud pass depth as a second parameter. By default it will output only one level.
Edit: optimized code a bit
I like this code, but i need the "Home" menu to be always included...thanks..please help..
-
Hi, I'm new to PW and php, and i need your help guys. My problem is im trying to include the "Home" menu to this code below that
slkwrm posted..can anyone help me?..tnx
function treeMenu($page, $depth = 1, $id = null) {$depth -= 1;
if(is_null($page)) $page = wire('page');
if(!is_null($id)) $id = " id='$id'";
$out = "\n<ul$id>";
$parents = $page->parents;
// This is where we get pages we want. You could just say template!=news-item
foreach($page->children() as $child) {
$class = "level-" . count($child->parents);
$s = '';
if($child->numChildren && $depth > 0 ) {
$s = str_replace("\n", "\n ", treeMenu($child, $depth));
}
$class .= " page-{$child->id}";
$class = " class='$class'";
$out .= "\n <li$class>\n <a$class href='{$child->url}'>{$child->title}</a>$s\n </li>";
}
$out .= "\n</ul>";
return $out;
}
//parameters: current page, menu depth, ul menu id
$menu = treeMenu($pages->get("/"), 2, "myMenu");
echo $menu;
E-Commerce with ProcessWire?
in Getting Started
Posted
Can anyone help me please....How can i build an e-commerce website using processwire?
I need some guidelines...Thanks