Create a quick index to Categories, Forms and Templates

From semantic-mediawiki.org
Jump to: navigation, search

Semantic extension(s): Semantic Forms

Further extension(s): -/-

Keyword(s): -/-

Description:

Problem

If you are using Semantic Forms, you probably end up having a list of Forms and Templates associated to Categories.

Assuming that you followed the recommended practice of using the same name for each namespace, you should have something like the following :

|Category:City    | Form:City       | Template:City
|Category:Country | Form:Country    | Template:Country
|And so on...     | And so forth... |

To simplify maintenance tasks, I wanted to generate a table with links to all three pages for each category.

Assumptions

  • You are using Semantic Forms and External Data extensions
  • You created a Form and a Template using the same name as their corresponding Category
  • You have created a template called 'Template:!' (see Note at the end of the tip)

Solution

I could not find a way to loop through the list of categories out of the box (or even using DPL).

Instead, I found it was possible to use the 'External Data' extension to help with this task:

1- Create a page called 'CategoryList' and copy the list of categories.

<includeonly>
Category
City
Country
</includeonly>

2- Create a second page called 'CategoryIndex' and insert the following query :

{{#get_external_data:<your server URL>/Special:GetData/CategoriesList|CSV with header|category=Category}}

{| class="standard-table"
! Category
! Browse data
! Simple Index
! Form
! Template
{{#for_external_table:<nowiki/>
{{!}}-
{{!}} [[:Category:{{{category}}}]]
{{!}} [{{fullurl:Special:BrowseData/Categories|_subcat={{{category}}}}} browse]
{{!}} [{{SERVER}}/Special:Ask/-5B-5BCategory:{{{category}}}-5D-5D/format%3Dcsv/sep%3D,/limit%3D5000 CSV]
{{!}} [[Form:{{{category}}}]]
{{!}} [[Template:{{{category}}}]]
}}
|}


3- Make sure to replace <your server URL> with your URL in both places (in the 'get external data' call and in the corresponding row).

The result will be a nice table with links to basic maintenance URLs for each Category and corresponding Forms and Templates.

Note: This tip assumes you already have template called 'Template:!' which contains simply the character '|'. This is a common trick to display '|' in nested template calls using '{{!}}' instead.