-
☆ A M B ☆
- 2,475 Posts
bluegum, my apologies, but I get the feeling that you maybe you misunderstand how the menus are created and are sorted using a script like Wayfinder. Any of the menu-generation scripts (like WayFinder) simply selects a series of documents from the database and sorts by the MENU INDEX, not by the page id -- the page id is pretty much irrelevant for this purpose... they’re not "messed up", they just have a sequential order that the menu doesn’t particularly care about. A lot of CMS’s do this type of thing where they use a "float" number or a "sink" number to determine where the items appear in the sort, and MODx is no exception; there is also the option to hide a particular page from appearing in the menu.
99% of the time, the order of the menu items is the same, no matter how you format it (i.e. the vertical and horizontal menus will contain the same items in the same order, but they don’t need to go to the same depth). If you need 2 menus to show entirely different items, then you’re going to have to write your own Snippet, but I’d HIGHLY recommend that you take a look at the sample site that comes in a default MODx install and deconstruct the WayFinder Snippet calls that are used in those templates. Some of the others in the thread have also posted helpful links detailing this common task of menu creation. The documentation on WayFinder is exhaustive -- it’s practically an eBook for your reference. I think you’d save a huge amount of time to research that and see if you can’t use it to solve your problem.
Hey, I’m using this:
[!Wayfinder? &startId=`[[UltimateParent]]` &level=`0`!]
to create a subnav on my sidebar. It shows all the pages in that main category just like I wanted and sets the active class so that it can be styled accordingly. Very nice! But my problem is that for some pages I’d like to include the main category (parent) in the list. Also, it would be useful to be able to set the active page to show as plain text, not linked. How can I do these things?
Thanks!
-
☆ A M B ☆
- 24,524 Posts
1. Use the &displayStart=`1` parameter, along with its &startItemTpl=`chunkName` tpl parameter. Example:
<h2>[+wf.linktext+]</h2>[+wf.wrapper+]
2. Use a different template for the "here" item, using the &hereTpl=`chunkName` parameter. Example:
<li[+wf.classes+]>
<span>[+wf.linktext+]</span>
[+wf.wrapper+]
</li>
http://www.muddydogpaws.com/development/wayfinder/parameters.html
Thank you, but I have to admit I still don’t get it. I just started using this application a few days ago. Should I wrap the wayfinder in a <div> or something? Where should I place the code examples you provided and should I edit them somehow?
Right now it looks like this:
[!Wayfinder? &startId=`[[UltimateParent]]` &displayStart=`1` &level=`0`!]
This will output (when browsing the parent page):
<h2 class="active">Parent</h2>
<ul>
<li><a href="/parent/child-1" title="Child 1" >Child 1</a></li>
<li class="last"><a href="/parent/child-2" title="Child 2" >Child 2</a></li>
</ul>
But I need the output to be something like:
<ul>
<li class="active"><a href="/parent" title="Parent" >Parent</a></li>
<li><a href="/parent/child-1" title="Child 1" >Child 1</a></li>
<li class="last"><a href="/parent/child-2" title="Child 2" >Child 2</a></li>
</ul>
-
☆ A M B ☆
- 24,524 Posts
That will take a little fiddling with the various output tpls.
You’ll need to have your startItemTpl carry the first part of the ul tag and put the text for the "parent" in the first li:
<ul id="topnav"[+wf.classes+]>
<li[+wf.classes+]>[+wf.linktext+]</li>
[+wf.wrapper+]
Then your outerTpl will handle the rest of the menu and the closing ul tag:
The [+wf.wrapper+] placeholder tells Wayfinder to continue doing its processing for the rest of the menu.
hi, I’m joining this conversation pretty late in the day. The explanation which mgrant gives is exactly what I am trying to do, and if I can do it with Wayfinder, that would be great. I have my top level navigation, ie. Home, Products, About etc, and then on each internal page, i am wanting to include a left hand nav which lists the 3 product categories. So my resource tree looks like this:
Home
Products
- Product A
- Product B
- Product C
About Us
Testimonials
etc
My problem is, when I insert the second navigation, and then tick the ’show in menu’ box on the product pages, ie. Product A, Product B, Product C, they all appear in the top navigation (and not in the left hand nav). I’m not sure how to specify to the wayfinder snippet that these pages should be excluded from the top nav, and instead be included in the left nav.
Am I missing a trick?
Sorry, I think I have answered my own question, by using the following code:
[[Wayfinder? &startId=`0` &level=`1`]] for the top nav (only displays level 1 links)
and
[[Wayfinder? &startId=`2` &level=`2`]] for the side nav (only displays level 2 links).
Hopefully this helps someone else out who may be facing the same dilemma.
Vicky