Replace list of pages in a Category by a semantic query
| Semantic extension(s): | Semantic MediaWiki |
| Further extension(s): | -/- |
| Keyword(s): | -/- |
Description:
Problem[edit]
Semantic Media Wiki (like Mediawiki) simply displays Category pages as a list of pages, in alphabetical order.
Depending on the type of page in your category, it could make more sense to replace that list with something more appropriate, such as :
- A Google Map if your category is about locations
- A Timeline if your category is about events
- A list of Open requests if your category is about requests
- and so on...
Solution 1[edit]
Assumptions[edit]
- You are using the CSS extension
Solution[edit]
The trick is to simply hide the page element containing the list of pages and replace it with your query.
1- Install the CSS extension if you don't have it yet, or ad
2- Create a new template : Template:HIDE_CATEGORY_PAGES
<noinclude>This template is meant to be used in Category pages to hide the default list of pages.</noinclude>
<includeonly>
{{#css:
/* #mw-subcategories {display: none} */
#mw-pages {display: none}
}}
</includeonly>
2- Open your category page ( for example : Category:Events )
3- Add the following line to hide the default list of pages :
{{HIDE_CATEGORY_PAGES}}
4- Add your query. For example, to display a timeline and list of recent events :
{{#ask:
[[Category:Event]]
|?Has start date = start
|?Has end date = end
|format=timeline
|link=all
|timelinebands=DAY,WEEK,MONTH
|timelineposition=end
|timelinesize=400px
|sort=Has start date
|order=desc
|limit=50
}}
{{#ask:
[[Category:Event]]
|?Has start date = start
|?Has end date = end
|format=table
|sort=Has start date
|order=desc
|limit=200
}}
Solution 2[edit]
This solution is ideal if you have only a few category pages requiring this replacement.
1- Put this into your Common.css (using Category:Events as an example):
body.page-Category_Events #mw-subcategories {display: none}
body.page-Category_Events #mw-pages {display: none}
2- Continue from step 4 above.
Solution 3[edit]
Install Extension:CategoryMagicWords to hide the pages output completely. Add you query directly or through a template to the category pages.