Difference between revisions of "Replace list of pages in a Category by a semantic query"

From Semantic MediaWiki Demo Wiki
Jump to: navigation, search
(new non-extension solution)
Line 13: Line 13:
 
* and so on...
 
* and so on...
  
== Assumptions ==
+
== Solution 1 ==
 +
 
 +
=== Assumptions ===
  
 
* You are using the [http://www.mediawiki.org/wiki/Extension:CSS CSS] extension
 
* You are using the [http://www.mediawiki.org/wiki/Extension:CSS CSS] extension
  
== Solution 1 ==
+
=== Solution ===
  
 
The trick is to simply hide the page element containing the list of pages and replace it with your query.
 
The trick is to simply hide the page element containing the list of pages and replace it with your query.
  
1- Install the [http://www.mediawiki.org/wiki/Extension:CSS CSS] extension if you don't have it yet
+
1- Install the [http://www.mediawiki.org/wiki/Extension:CSS CSS] extension if you don't have it yet, or ad
  
 
2- Create a new template : Template:HIDE_CATEGORY_PAGES
 
2- Create a new template : Template:HIDE_CATEGORY_PAGES
Line 73: Line 75:
  
 
== Solution 2 ==
 
== Solution 2 ==
 +
 +
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):
 +
<pre>body.page-Category_Events #mw-subcategories {display: none}
 +
body.page-Category_Events #mw-pages {display: none}</pre>
 +
 +
2- Continue from step 4 above.
 +
 +
== Solution 3 ==
 
Install [http://www.mediawiki.org/wiki/Extension:CategoryMagicWords Extension:CategoryMagicWords] to hide the pages output completely. Add you query directly or through a template to the category pages.
 
Install [http://www.mediawiki.org/wiki/Extension:CategoryMagicWords Extension:CategoryMagicWords] to hide the pages output completely. Add you query directly or through a template to the category pages.

Revision as of 10:58, February 3, 2012

Extension: Semantic MediaWiki

Description:

Problem

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

Assumptions

  • You are using the CSS extension

Solution

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

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

Install Extension:CategoryMagicWords to hide the pages output completely. Add you query directly or through a template to the category pages.