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
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
- Istorijska Biblioteka Draws Attention In Scientific Circles: istorijska_biblioteka
- CSS Per Category — Including Inexisting Pages!:
- Gallery with external images: gallery images listpages playground
- Advanced Search!: csi search
- Russian Wikidot Handbook started!: handbook russian
- Applications for Wikidot available: appplication mass-edit
- CSS Playground !:
- New: Autosave function in module NewPage: autosave blog newpage
- New: Set tags button (for update tags) available: blog button notgood open tags
- Calendars for Wikidot !: blog calendar
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
ErichSteinboeck. Please visit his/her userPage.
James Kanjo. Please visit his/her userPage.
Other(!) HowTos posted by ErichSteinboeck
- Include Inline
- Include Part Of A Page Only
- Include With Defaults
- How Many Days Does Your Wiki Exist
- Feed/FrontForum/ListPages/live template — %%date%%
- Include Part Of A Page Only (Tricky Version)
- Date: How Long Ago?
- Set Up An Infobox
- System Variables: Details
- Iframe Link
- Page Count
- Direct Links to Sub-Pages of System Pages
- Set Up an Infobox — Exclude Specific Attributes
- System Variables
- Include a Forum Thread
- Module Attributes via URL
- Nested Comments
- Create Sortable List of Pages






This is very clear in the usage - and makes sence too!
Congratulations !
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 ?
Erich,
Nice work! You are the Master Manipulator of the comment tag!
-Ed
Free Wikidot Applications · Your Shared Photo Gallery · Your Personal Blog
Will be using this! :)
Shane Smith ★ Website: Wikidot Development & Programming.
STE Wikidot Editor: Windows & Mac OS X. ★ Try it for free!.
I'm also on Twitter, follow me there! ;-)
I refined the code to utilise a single ListPages module rather than two. As I was using the old code, I came across limitations due to trying to use a span element across different div blocks (which are automatically created as part of the ListPages module).
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
Thanks James, now please apply this solution to James Kanjo's activity …
I especially like this because it is not limited to English, and anyone can write the text in his own language… Well done, guys!!!!
PS:I have already implemented it in Candidate For Delete (List) page….
Vir bonus miser vocari, at esse non potest miser.
Erich's how-to addresses instances when a list is empty. I'm trying to think of how to distinguish between lists with 1 and more entries.
"1 comments" sounds too automated.
For the meantime, I've been using "1 comment(s)". Maybe this is possible with includes. Let me see…
— Blog ~ Life's Handbook ~ Wikidot Design & Development
I tend to use "Number of comments: 1" as that works whatever the number is.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Strathview ~ Wikidot-based wikis, websites & intranets and online database development. For community groups, villages, charities, business and government.
I tried using some includes to do the job, and it worked well when not using ListPages. The problem was that defining %%comments%% as the value instead of 1 broke the idea. So for the moment, Rob's idea seems best, and it could be shortened to simply, "Comments: 1".
— Blog ~ Life's Handbook ~ Wikidot Design & Development