Top Nav Menu with ListPages

By Helmut_pdorf Helmut_pdorf

Description

You are able to automatically build a Menu strucure on your Top navigation bar with the ListPages module - by selecting only a specific category (or tag, or combinations):

  • use the separate= "no" attribute (inserts no div's per entry)
  • use the prependLine attribute with the content of the menu-header - either
    • a literal like prependLine="* [# Menu-pages]" or
    • a link to a page like prependLine="* [[[start-buchecke | Buchecke]]]"
  • use as <custom body> of the ListPages module
    • a comment line as 1. line AND
    • as 2. line the " * %%linked_title%%" variable ( notice the space before the star!)
  • if you want you can use the limit="nn" attribute for security only not to explode the top nav menu…

Code

[[module ListPages category="buchecke" separate="no" prependLine="* [# Buchecke]"]]
[!-- --]
 * %%linked_title%%
[[/module]]
[!-- notice the comment (2.) line and the space before the star (in the 3. line --]

Notes

1. The secret is the comment line before the variable line.. I forgot who have detected this…
Why ? The parser eliminates every space before and after a parameter value. Means: instead of " * xyz" the result is "* xyz" and the important space before the "*" is gone.
With a comment (line) before the variable the parameter has the content of "[[!-- any comment --] * Xxx" and the important space before the "*" is not erased. (Thanks to ErichSteinboeck who explained the reason in detail).

2. Another important issue is the possible, but unneccessary and dangerous space line between the different menu-items:

Avoid any blank line between the menu items. Wrong is following code:

* [[[start | Menue]]]
 * [[[start | Willkommen]]]
 * [[[Nachrichten]]]
* [[[forum:start | Forum]]]
 * [[[forum:recent-posts | Neueste Post]]]
 * [[[forum:minirecent-threads | Neueste Threads]]]
* [# Hilfe]
 * [*http://www.wikidot.com/doc Documentation]
 * [*http://www.wikidot.com/doc:wiki-syntax wiki-syntax]
* [[[contact]]]

The blank lines will create stairsteps-like menu-bars on some themes..
( thanks to mattdm for this findings)

Better is always to avoid the blank lines:

* [[[start | Menue]]]
 * [[[start | Willkommen]]]
 * [[[Nachrichten]]]
 * [[[neue-seite-anlegen | Neue Seite anlegen]]]
 * [[[system:join| Site Mitglied werden]]]
* [[[forum:start | Forum]]]
 * [[[forum:start | Gruppen-Übersicht]]]
 * [[[forum:recent-posts | Neueste Post]]]
 * [[[forum:minirecent-threads | Neueste Threads]]]
[[module ListPages category="buchecke" separate="no" prependLine="* [[[start-buchecke | Buchecke]]]"]]
[!-- --]
 * %%linked_title%%
[[/module]]
* [# Hilfe]
 * [*http://www.wikidot.com/doc Documentation]
 * [*http://www.wikidot.com/doc:wiki-syntax wiki-syntax]
 * [*http://community.wikidot.com/howto:howto-list How-To's]
 * [*http://handbook.wikidot.com/ HANDBUCH]
 * [[[How to edit pages?]]]
* [# Internals]
 * [[[system: Recent changes]]]
 * [[[system: List all pages]]]
 * [[[admin:manage|Site Manager]]]
* [[[contact]]]

In action

Easy to show..I used above code on a public site Turnen at bp:
have a look on the top nav menu point "Buchecke" - the entries are build automatically with the code inserted above!


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by Helmut_pdorf

Sorted-ListPages-List - 06 Jun 2021 03:46
Todo List with Data Forms - 30 Apr 2015 14:59
Html(embed) code opening in new window/tab - 29 Oct 2014 09:05
Facebook Button - 27 Dec 2013 15:03
Advanced Search - 25 Feb 2012 12:29
Schedules - 16 Feb 2012 01:40
Use any html code on a page - 16 Feb 2012 01:34
Find untagged pages - 15 Feb 2012 00:52


Rate this solution

If you think this solution is useful — rate it up!

rating: +17
I restored my deleted example - site...
Helmut_pdorf Helmut_pdorf 17 Jul 2012 11:37

By chance I have deleted my old example site … and now I restored it… but noiw I detected this site is "private"… I need another test site to show this in action…!


Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.

Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?

by Helmut_pdorf Helmut_pdorf , 17 Jul 2012 11:37
Having trouble with breaks?
Bendtsen Bendtsen 17 Jul 2012 06:42

The listpages module causes a div-block, which in (some?) themes causes a break before/after. You will have to make a custom theme based on your chosen theme where you modify the css to make sure that both the #top-bar ul as well as the list-pagesbox are inline elements:

Admin Manage—> appearences —>Custom Theme —> New

.list-pages-box{
display:inline;
}
#top-bar ul{
display:inline;
}

Last edited on 18 Jul 2012 10:41 by Bendtsen
by Bendtsen Bendtsen , 17 Jul 2012 06:42
weinerschnitzel weinerschnitzel 13 Apr 2011 00:04

I am having issues as well with the module adding unwanted spaces to my nav:top menu. These spaces create new lines with my theme. I don't want to change the theme, is there a hack for removing the spaces the module adds before and after the page list?

by weinerschnitzel weinerschnitzel , 13 Apr 2011 00:04
leiger leiger 14 Apr 2011 05:56

Looking at http://surreal64ce.wikidot.com/nav:top I notice that you haven't got the ListPages code in there at the moment.

There is probably a way to do this using either wikidot syntax or CSS, but I can't help you find a solution until I get home (CSS themes not working for me at the moment). Only thing I can suggest is to try it in the middle of two regular menu items, rather than putting the ListPages module at the beginning or end of the list of menu items. And to avoid blank lines.


~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server

by leiger leiger , 14 Apr 2011 05:56
Ez0n3 Ez0n3 14 Apr 2011 20:21

It seems that:

prependLine="* [# Buchecke]"]]

Creates a new "<li>" item in the unordered list, but it doesn't add the proper closing "</li>" which causes the top nav to stair-step.

Hard coded:

* [# Navigate]
 * [[[item1| Item 1]]]
 * [[[item2| Item 2]]]
 * [[[item3| Item 3]]]

Result in HTML:

<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>

Then with the ListPages module:

* [# Navigate]
 * [[[item1| Item 1]]]
[[module ListPages category="item2" separate="no" prependLine="* [[[item2| Item 2]]]"]]
[!-- --]
 * %%linked_title%%
[[/module]]
 * [[[item3| Item 3]]]

Result in HTML:

<ul><li>Item 1</li><li>Item 2 <!-- no </li> here causing it to stair-step --><li>Item 2 - A</li><li>Item 2 - B</li><li>Item 2 - C</li><li>Item 3</li></ul>

It almost seems like it should be:

prependLine="* [[[item2| Item 2]]] </li>"

But it doesn't render the inline html properly :(
by Ez0n3 Ez0n3 , 14 Apr 2011 20:21
soronlin soronlin 20 Jul 2010 13:14

Caution: ListPages inserts a div into the menu. This will probably be invisible to most themes, but it may cause problems in rare cases.

In my case I am listing help pages, and it is possible that over time too many pages will be created to put them all in a menu. So I limited the list to ten items and added a "More…" item at the bottom of the list that brings up an index page (as does the top-level menu item itself.)

[[module ListPages category="*" limit="10" separate="no" parent="help"
 prependLine="* [[[help| Help]]]" appendLine=" * [[[help |More...]]]"]]
[!-- --]
 * %%linked_title%%
[[/module]]
by soronlin soronlin , 20 Jul 2010 13:14
experiential experiential 17 Mar 2011 05:37

I am using the Webbish (default) theme. But when I use listpages in nav:top, the menu items get listed vertically?
I need the menu items horizontal. In some themes, I get the desired result. But I am a big fan of the Webbish default theme and want to keep using it.

Also in the listpages list, can I add a horizontal line (separator), so that it is easy to make out individual list items?

can u help?

Last edited on 17 Mar 2011 06:11 by experiential
by experiential experiential , 17 Mar 2011 05:37
Helmut_pdorf Helmut_pdorf 17 Mar 2011 09:17

Than you should try without the comment line ( which inserts the blank before the star) and without the prependLine="* [[[Start_menu..xyz]]]"

But do not forget the limit="4" or so … or you will explode the nav:top bar

I cannot test this now on ome of my sites..

Edit: I use such listpages on my test-site: http://helmuti-pdorf.wikidot.com/nav:top ( "flash" menu) - and "iftags" to show different menus…


Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.

Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?

Last edited on 17 Mar 2011 09:30 by Helmut_pdorf
by Helmut_pdorf Helmut_pdorf , 17 Mar 2011 09:17
page revision: 8, last edited: 16 Feb 2012 01:48
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).

AltStyle によって変換されたページ (->オリジナル) /