ListPages: Automatic Header

Posted by ErichSteinboeck on 25 Mar 2009 15:29, last edited by James Kanjo on 09 May 2010 05:54

Tags: automatic header heading listpages

rating: +6+x

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.

Example

Click on a tag to list Community Blog pages tagged with any tag, listpages, howto, xyzzy

Below you'll find a list of pages tagged with the selected tag

  1. Multi-PM Bookmarklet available:
  2. ListPages now supports updated_at selection: listpages updated_at
  3. Google +1 Button Snippet:
  4. Wikidot Extension - Mass Delete Tool and more: app autocomplete etension file-manager mass-delete
  5. Wikidot 101 - Video Tutorials: help howto tutorial
  6. Fixing Old Data Forms: bug convert data-forms fixing wikidot yaml
  7. simpleCal: simply. calendars.: calendar simplecal
  8. Firefox-Wikidot-Toolbar found - test it!: button firefox toolbar
  9. Istorijska Biblioteka Draws Attention In Scientific Circles: istorijska_biblioteka
  10. CSS Per Category — Including Inexisting Pages!:

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"
appendLine="heading-text-to-be-shown-if-no-pages-are-displayed[!----]"]]
heading-text-to-be-shown-if-at-least-one-page-is-displayed
[!----]
listpages-body-that-usually-contains-%%…%%-variables
[!--
[[/module]]

Backlinks

Authors

ErichSteinboeckErichSteinboeck. Please visit his/her userPage.

James KanjoJames Kanjo. Please visit his/her userPage.

Add a New Comment

Related articles

Comments

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.