Page 1 of 1
[SOLVED] seeking help with setting up dynamic menus
Posted: Wed Mar 10, 2010 10:23 pm
by gdur
Hi,
Here is what I would like to achieve.
Horizontal top menu only one level which is easy.
I've set up a block on the left side and would like to display the child pages (submenu) or links one level down and again one level.
If a link is selected having childs again I would like to display these instead as the next submenu. Once there are no more childs left I would like to display the same level plus a link for one level up. If the main (top) menu item does not have childs I would like to hide this specific block.
I tried a lot assigning all kinds of variables on various places but nothing leads to anything close while I'm convinced it should be possible.
So the question is; how and where do I determine which item from the top menu has been selected while knowing at the same time whether childs are involved. How to input this in my template to manipulate the block behaviour (show or hide) and how to prevent an empty menu once there are no childs left over.
What I'm trying to achieve is partly implemented, have a look at
http://83.98.128.43/~duran/index.php?pa ... s&hl=en_US
The top menu is still multi level in order to be able to navigate.
Any help will be highly appreciated!
Re: seeking help with setting up dynamic menus
Posted: Wed Mar 10, 2010 11:46 pm
by lollipop27
Hi,
haven't completely understood what you want to acheive, but sounds like a great challenge regarding the MenuManager...
I had a very specific problem once too. Then Calguy100 wrote me some genious comtum tags, since then I could solve every Menu problem... Perhaps these UDT's will help you.
"get_page_menutext"
"get_parent_page_alias"
"get_page_depth"
http://forum.cmsmadesimple.org/index.ph ... l#msg82522
Cheers.
Re: seeking help with setting up dynamic menus
Posted: Thu Mar 11, 2010 8:54 pm
by lollipop27
Hi there,
as far as I understand this, it more than the default submenu.
You have implemented it this far:
if I choose products you diplay the children of products.
if I choose intellivox, you display the children of intellivox
if I choose Intellivox-DC115 you display nothing,
but you wanna display the siblings of Intellivox-DC115 and a link to the parent, meaning intellivox.
Am I right so far?
So you usually display the children. You got it that far. Then you need a UDT that tells you if that page has children. if not, then find out the level (you can do that with the UDTs I posted above) and display that level (siblings). futheron you find out the parent page alias (as well possible with UDTs above) and display that link too. (to display the menutext you have the third UDT)
So what you have to do is a UDT that tells you wheter your page has children or not. right??
Re: seeking help with setting up dynamic menus
Posted: Thu Mar 11, 2010 10:30 pm
by gdur
Hi Lollipop27, Dr Css,
First of all thanks very much for your responses!
Lollipop27 you are absolutely right! The only one thing missing is to show and hide the block itself if there's nothing to display.
I tried a lot to discover where to assign a variable to tell whether the block should be hidden or not but this is anyway not the most important. Other then that I think you have understood what it is I'm trying to achieve. The reason for this is that I believe the standard behaviour of the menu system is a bit against the conventions of pulldown menu's. Usually if there are children the main level does not contain a feature. This makes that people (and I allready have had this comment) skip the specific page. That's why I would like to display the top menu just single level. This bring people to a "general" or "catagory" page while at the same time pointing the way by displaying the options in the left menu without missing a important page.
So the suggestion of Dr CSS is not valid for this approach since in the example the top menu disappears once the side menu pops up. It's not that I haven't explored all that as well as many of the tips I found on the forum. The problem might be my lack of php, css, html, java experience but since I do have quit a lot of experience coding xbase, pascal and the like I should be able to find my way around but was hoping getting somewhere without spending the time right away.
Oh yes, siblings I came accross a couple of times in many examples. The problem is that my english is too poor to understand the meaning. Is there possibly somehow an explanation what it means?
Once again lollipop27, I'm sure my family will have to do it without me this coming weekend because I surely will dive in the UDT's you have submitted in your first response!
Another thing I came accross is the following styling issue while using the standard menu templates which came with the install ( I did try all that!); when using for instance the cssmenu.tpl for the left side menu. While placed within the block definition the slide-out menu is only displayed till the edge of the block area. Is there a way to get this behaviour some how " on-top" and have it slide over the center content? I couldn't find any answer on the web but maybe I'm using the wrong search arguments.
Once again and thanks a lot for all the help and I will let you know I get on.
Re: seeking help with setting up dynamic menus
Posted: Thu Mar 11, 2010 11:30 pm
by gdur
Dear Dr CSS,
Thanks but you must have misunderstood. The link you just have posted only shows the breadcrumbs and not a top menu!
I mean a slide-out submenu to the right.
Re: seeking help with setting up dynamic menus
Posted: Fri Mar 12, 2010 12:42 pm
by lollipop27
About the sliding menu, I thing Dr. Css meant this link:
http://multiintech.com/defaultcontent/i ... u_vertical
and you can see, it goes over the side content...
gdur wrote:
The only one thing missing is to show and hide the block itself if there's nothing to display.
Well that shouldn't be too much of a problem.
if there are no children but a parent then you display the parent and if there are no children and you are in the first level, then display nothing. you can do that with the UDTs I mentioned...
gdur wrote:
Oh yes, siblings I came accross a couple of times in many examples. The problem is that my english is too poor to understand the meaning. Is there possibly somehow an explanation what it means?
Siblings are brothers and sisters... so if you are at the page # Intellivox-DC115 these are the siblings:
# Intellivox-DC180
# Intellivox-DC280
# Intellivox-DC430
# Intellivox-DC500
# Intellivox-DC808
# Intellivox-DC1608
well.. i think you should check the UDTs and it will solve most of your problems...
have a great weekend.

Re: seeking help with setting up dynamic menus
Posted: Fri Mar 12, 2010 9:19 pm
by gdur
Hi Lollipop27
Thanks again for your help.
Yes, I think you are right, this is likely what Dr CSS meant. And yes the menu is flying over the content. I can't get this to work but I guess this is pure css related(?). Again, it's not that important since I'm not planning to use it anyway once I get the other stuff to work but to know how could be useful in the future.
I've been playing with the UDT's but having trouble to figure out where to place them in order to get the right info.
The whole exercise feels like backwards engineering by trial and error lacking the necessary info in one place.
You've understood correctly what I want to achieve, once in the lowest level I want to display the siblings (thanks for the explanation) plus the level above to offer ease of navigation. If I want the list to start with the level above page this needs to be defined before diving into the "foreach" loop in the sidemenu template. I've tried to grab the information needed at this point but the answers I get, using {$node->url} and {$node->menutext} in order to create the href, is the last page of the toplevel (in my case the feedback page). The foreach statement follows after a $count statement in the menu template. I only have a vague idea that $count is counting the nodes (but starting at what position, represented by $nodelist?) and once the value is > 0 the foreach loop is executed. Since the foreach loop results in the list I assumed the count is starting at the level above.
I took a little intermezzo and searched what I could find on $count and found this topic (
http://forum.cmsmadesimple.org/index.php?topic=35416.0 ) someone running into the same problem and I was shocked by the answer given by one of the dev team members. {get_template_vars} or if you want a print-out of an object... This really sounding like sending someone into the dark forest. No wonder he turned his back to cmsms, what a shame.
So it is indeed backwards engineering? I've been using {get_template_vars} myself for the last couple of days in trying to understand what goes on, but now I'm afraid this is going to be a hell of a job without help.
Having said that I do hope you could provide me some more guidelines towards a working piece of code.
I'm using a slightly modified template (list_children) from the menu manager documentation since this one appeared to be the nearest to my objective.
Code: Select all
{assign var="depth" value="-2"}
{assign var="depthcheck" value="0"}
//* added the following 2 lines to print the level above, doesn't work though.
<ul class="menu_vert">
<li><a href="{$node->url}">{$node->menutext}</a><br /></li>
{if $count > 0}
{foreach from=$nodelist item=node}
{if $node->index == 0}
{*assign var="icon" value="house"*}
{elseif $node->haschildren == true }
{*assign var="icon" value="folder"*}
{elseif $node->haschildren == false }
{assign var="icon" value="page"}
{/if}
{if $depthcheck == 1 && $node->depth != $node->prevdepth}
<ul class="menu_vert">
{assign var="depth" value=$node->depth}
{assign var="depthcheck" value="0"}
{assign var="listopened" value="1"}
{/if}
{if $node->depth == $depth}
<li>
<a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a><br />
</li>
{/if}
{if $node->current == true && $node->haschildren == true}
{assign var="depthcheck" value="1"}
{/if}
{/foreach}
{if $listopened == 1}
</ul>
{/if}
{/if}
looking forward to your response and have a nice weekend too!
Re: seeking help with setting up dynamic menus
Posted: Sat Mar 13, 2010 3:10 pm
by lollipop27
ok. i haven't gone throught your navigation template....
but:
why don't you do something like this...
{get_page_depth assign="depth"}
{get_parant_page_alias assign="parent" page=$title}
{get_page_menutext assign="parent_menutext" page=$parent}
{if $depth > 1}
{$parent_menutext}
{/if}
this should give you the link to the parent...
[SOLVED]Re: seeking help with setting up dynamic menus
Posted: Sat Mar 13, 2010 8:59 pm
by gdur
Hi Lollipop27,
Thanks once more! Your suggestions were helpful in a way and I have used it as well in one place (to print the toplevel in my side menu while selecting one level lower). Just have a look and you'll see. Other then that I'm learning more and more and finally got there as well, at least visible it fulfills the objective. At this point I'm sure the code I came up with is messy and far from efficient but I save cleaning up for another time. But like I remarked before, there's a lot backwards engineering involved.
If an "exit" statement would have exist to escape from the "foreach" loop, that would have made live a lot more easy, at least in this case. Anyway, it might be better to first absorb all there is in writing and then start to criticise.