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. List pages for current logged in user only: listpages listusers logged-in-user-only
  2. ListPages now supports updated_at selection: listpages updated_at
  3. Gallery with external images: gallery images listpages playground
  4. New Listpages Module and _templates variables: listpages module syntax templates
  5. New ListPages - and Comments - Parameter: comment listpages module news syntax
  6. Page Count: count javascript listpages pages
  7. How-To: Automatic ListPages Header: automatic header listpages
  8. New List Pages By Category: category list listpages live pagecalender pages template
  9. Featured Wikidot Sites Remixed: listpages thumbnails
  10. Guestbook now uses ListPages and _template: listpages template

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.