Widget:CategoryPages: Difference between revisions

From Nottinghack Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
   <script type="text/javascript">
   <script type="text/javascript">
     (function() {
     (function() {
       const url = '/api.php?action=query&list=categorymembers&cmtitle=Category:<!--{$category|escape:'quotes'}-->&format=json&cmlimit=40';
       const url = '/api.php?action=query&list=categorymembers&cmtitle=Category:<!--{$category|escape:'html'}-->&format=json&cmlimit=40';
       fetch(url).then(function(response) {
       fetch(url).then(function(response) {
         return response.json();
         return response.json();

Revision as of 01:03, 24 January 2025

This widget uses the MediaWiki API to request a list of pages within a category, and spits them out into a div. It takes one parameter, which is the category name. This is done on the client side, using JavaScript, which is less than ideal. It can only be used once on a page. It is currently only used by Template:Location Tools.

Example

{{#widget:CategoryPages|category=Tools and Equipment in Electronics Area}}

Parameters

category
The name of the category.