Posted by ErichSteinboeck on 25 Mar 2009 15:29, last edited by GoVegan on 09 May 2010 05:54
: 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
- Compromised Accounts On Wikidot:
- Happy New Year 2024 !:
- New Phrase In Translation Wiki (2023年09月20日):
- New Phrases Waiting For Translation Since June 2022: 2022 translate
- Happy New Year 2023 !: 2023 newyear
- New phrases waiting for translation since May 2022: 2022 translate
- Happy New Year 2022!: 2021 newyear
- Wikidot under attack?: attack
- Happy New Year 2021 !: 2021 newyear
- Login Problems with Custom Domain (Chrome): chrome custom_domain login problems
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 ErichSteinboeck . Please visit his/her userPage.
James Kanjo James Kanjo . Please visit his/her userPage.
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
Will be using this! :)
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server
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).
Thanks James, now please apply this solution to James Kanjo's activity …
lowkarma.pnggerdami - Visit Handbook en Français - Rate this howto:import-simple-excel-tables-into-wikidot up!
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 page….
If slaughterhouses had glass walls, everyone would be vegan. - Paul McCartney
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…
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
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.
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".
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Getting a weird issue when I try to use this in a template with a CountPages module for a header. I'm using:
[[module ListPages parent="." separate="false"
appendLine="[!----]"]]
+++ Subcategories
----
[[module CountPages parent="."]]
This category has the following %%total%% subcategories.
[[/module]]
[!----]
* %%title_linked%%
[!--
[[/module]]
All pages with no subcategories (i.e. child pages) should show nothing there. That works fine. But on the page I'm having trouble with (called "Characters"), which has one child page (called "Doctors"), I should be getting:
Subcategories
This category has the following 1 subcategories.
- Doctors
Instead, I'm getting:
Subcategories
[some number]512223Characters
The number doesn't seem to have any relation to anything. It seems to change based on parameters I haven't figured out. Right now it's 98, but at one point it was something like 136. (And just now I changed "separate" from "false" to "no" and got 33626.)
However, if I open the editor and preview the page, I always get:
Subcategories
appendLine="[!----]"]]
- Doctors
It's all terribly strange. I'm pretty sure it was working earlier, while I was still fooling around with the template. I'm not sure when it stopped working, so I don't know what change caused the problem.
It shouldn't work, as you cannot nest modules inside one another. Thankfully, you do not need CountPages at all since ListPages supports the %%total%% variable all on its own.
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Yes, but if I used the ListPages module by itself, it would give that message for every page listed.
…Eeeexcept no it wouldn't because the whole point of the comment tags is to stop it from doing that, isn't it? Oh my Lord I'm a moron. XD Forgive me, I'm very new at all this.
No problem; we're here to help when needed (:
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Related articles
Comments
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
Will be using this! :)
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server
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).
Thanks James, now please apply this solution to James Kanjo's activity …
lowkarma.pnggerdami - Visit Handbook en Français - Rate this howto:import-simple-excel-tables-into-wikidot up!
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 page….
If slaughterhouses had glass walls, everyone would be vegan. - Paul McCartney
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…
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
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.
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".
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Getting a weird issue when I try to use this in a template with a CountPages module for a header. I'm using:
[[module ListPages parent="." separate="false"
appendLine="[!----]"]]
+++ Subcategories
----
[[module CountPages parent="."]]
This category has the following %%total%% subcategories.
[[/module]]
[!----]
* %%title_linked%%
[!--
[[/module]]
All pages with no subcategories (i.e. child pages) should show nothing there. That works fine. But on the page I'm having trouble with (called "Characters"), which has one child page (called "Doctors"), I should be getting:
Subcategories
This category has the following 1 subcategories.
- Doctors
Instead, I'm getting:
Subcategories
[some number]512223Characters
The number doesn't seem to have any relation to anything. It seems to change based on parameters I haven't figured out. Right now it's 98, but at one point it was something like 136. (And just now I changed "separate" from "false" to "no" and got 33626.)
However, if I open the editor and preview the page, I always get:
Subcategories
appendLine="[!----]"]]
- Doctors
It's all terribly strange. I'm pretty sure it was working earlier, while I was still fooling around with the template. I'm not sure when it stopped working, so I don't know what change caused the problem.
It shouldn't work, as you cannot nest modules inside one another. Thankfully, you do not need CountPages at all since ListPages supports the %%total%% variable all on its own.
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Yes, but if I used the ListPages module by itself, it would give that message for every page listed.
…Eeeexcept no it wouldn't because the whole point of the comment tags is to stop it from doing that, isn't it? Oh my Lord I'm a moron. XD Forgive me, I'm very new at all this.
No problem; we're here to help when needed (:
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me