0

I have a basic MediaWiki installation with several categories (which is sorted automatically). In each category I have several links to articles. These links are listed in a simple star (*) list, which is not sorted automatically.

I know I can use a table but 1) that seems counter-intuitive to me, 2) I want the list of articles to be sorted automatically rather than having a interactive table where the user has to sort manually and 3) I want a clean, easy list without borders, preferably with that preceding circle. I could also use sub-categories, but because I'm a weird duck (lazy or maybe just adamant to solve this using lists as I feel this should be doable) I want to explore this route first.

Is there a somewhat easy solution for this? Either with css, js, html(?), extension or other? I have extremely little experience in this matter and would have to ask that any answers is given in layman's term (e.g. solution/step-by-step guide on silver platter, if at all possible).

What I want is for:

* [[Example article 1]]
* [[Article 2]]
* [[Etc]]

To become:

  • Article 2
  • Etc
  • Example article 1

Instead of:

  • Example article 1
  • Article 2
  • Etc
2
  • It seems to me that you misuse categories. If you add [[Category:Some category]] to some pages, the page Category:Some category will contain an ordered list of those pages, Jul 9, 2021 at 9:42
  • I realize that (hence my comment on "sub-categories" (category in category, I guess)) and that might even be best practice, I don't know. I would still like to be able to automatically sort a simple list, though, if possible. If for no other reason, then because my wiki is already set up impractical and I would like to avoid converting all the relevant pages to categories... :)
    – Morten
    Jul 9, 2021 at 10:42

1 Answer 1

0

If you want to be able to sort a simple list server-side, install Scribunto, create Module:Utils containing

return {
    sort = function (frame)
        local trim = mw.text.trim
        -- Since frame.args is not a real table, it has to be copied:
        local args = {}
        for _, arg in ipairs (frame.args) do
            args [#args + 1] = trim (arg)
        end
        table.sort (args)
        return table.concat (args, '\n')
    end
}

and invoke the sort function from the wikitext like this:

{{#invoke:Utils|sort
| * 2. Second
| * 1. First
| * 3. Third
}}

If you want to sort a table client-side, add sortable class to it, as described here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.