Posted by ErichSteinboeck on 25 Mar 2009 15:29, last edited by James Kanjo on 09 May 2010 05:54
When using module ListPages to select pages by specific criteria, there are two possible outcomes:
- at least one page matches the criteria (resulting in a list of pages to be displayed), or
- none of the pages match (resulting in nothing to be displayed)
You'd sometimes want the heading text for the list of pages to automatically adapt to the above situations, e. g. to show a heading text like
- “Below you'll find a list of pages” if one or more pages are displayed, and
- “No pages match” if ListPages does not display any pages
Here is a way, how you can do that.
Below you'll find a list of pages tagged with the selected tag
- Bootstrap'd Forum (WIP): bootstrap css forum theme
- Talk with us on IRC: community internet multilingual wikidot
- Multi-PM Bookmarklet available:
- ListPages now supports updated_at selection: listpages updated_at
- Google +1 Button Snippet:
- Wikidot Extension - Mass Delete Tool and more: app autocomplete etension file-manager mass-delete
- Wikidot 101 - Video Tutorials: help howto tutorial
- Fixing Old Data Forms: bug convert data-forms fixing wikidot yaml
- simpleCal: simply. calendars.: calendar simplecal
- Firefox-Wikidot-Toolbar found - test it!: button firefox toolbar
This is how the above example was coded:
[[module ListPages tag="@URL" category="blog" limit="10" separate="false" appendLine="//No pages are tagged with the selected tag//[!----]"]] //Below you'll find a list of pages tagged with the selected tag// [!----] # %%linked_title%%: %%tags%% [!-- [[/module]]
How it Works
Because the "pages available" code is within the ListPages body, it will only display if there are any pages matching the ListPages criteria. Hidden comments are used to ignore the "pages available" message for every page after the first one — the ending [!-- code of the ListPages body is responsible for this. However, when the last page of the matching criteria is displayed, the ending [!-- code will instead hide the "pages unavailable" message.
Note: you must type the shown Wikidot comments ([!----]) and ([!--) exactly as-is. They are required to perform the desired function.
[[module ListPages selection-criteria separate="false"