Mobile app version of vmapp.org
Login or Join
Nimeshi995

: How to use a user preference in a Mediawiki template In a mediawiki page, I would like to have a checkbox that applies to all pages so that templates on the page can use the value of

@Nimeshi995

Posted in: #Forms #Mediawiki

In a mediawiki page, I would like to have a checkbox that applies to all pages so that


templates on the page can use the value of the checkbox
when the checkbox is changed, the page refreshes.


The checkbox could be used, say to relegate details in the text into footnotes. E.g. an editor could write
"Trains from Bristol Parkway {{Details|opened in 1971}} go to London."
The user would see
"Trains from Bristol Parkway^1 go to London" or "Trains from Bristol Parkway (opened in 1971) go to London" depending on their preference.

The template "Details" would be something like

{{#ifeq:UserPreference|IncludeDetailsInText|({{{1|}}})|<ref>{{{1|}}}</ref>}}


How do you fetch the UserPreference?
Should I use a Widget?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Nimeshi995

1 Comments

Sorted by latest first Latest Oldest Best

 

@Murphy175

This worked.

Use www.mediawiki.org/wiki/Extension:Widgets to put a checkbox on your page and then use www.mediawiki.org/wiki/Extension:UrlGetParameters to read the value the user chooses for the checkbox into a template.

The Widget is Widget:Checkbox

<form action="" method=GET>
<input type="checkbox" name="footnoteintext">Include footnotes in text
<input type="submit" value="Update">
</form>


The template for showing the footnote is Template:FootnoteOptional

<noinclude>
This is the "FootnoteOptional" template.
It should be called in the following format:
<pre>
{{FootnoteOptional
|Note=
}}
</pre>
Edit the page to see the template text.
</noinclude><includeonly>{{#if:{{#urlget:footnoteintext}}| ({{{Note|}}}) |{{#tag:ref|{{{Note|}}}}}}}</includeonly>


The text on the page is

Bristol Parkway {{FootnoteOptional|opened in 1971}} ...

{{#widget:checkbox}}

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme