Topic on Project:Support desk

Jump to navigation Jump to search
FrugalTPH (talkcontribs)

How would I go about inserting an mbox/abox on any page a user visits which is protected from them?

MarkAHershberger (talkcontribs)

How are you protecting the pagss?

FrugalTPH (talkcontribs)

Using the built-in More > Protect function, and selecting "Allow Only Administrators", infinite. Reason = "This policy is set by the shareholders". It would be nice if I could show the reason as part of the mbox, a little like the mbox they use here to show Archived Extensions, e.g.


<img of a padlock to the left of the text>

This page is Protected

Authority: <username who locked it>

Reason: <reason given for protection>

MarkAHershberger (talkcontribs)

You could use Scribunto to check a page's protectionLevel and display a template if necessary.

FrugalTPH (talkcontribs)

Thanks for responding @MarkAHershberger.

I've made an appropriate template to insert, but am unsure about how to have that auto-insert at the top of any protected page. Would I do that via MediaWiki:Common.js?

AhmadF.Cheema (talkcontribs)

One method could be to export Wikipedia's Module:Protection banner or some other protected template with the Include templates option checked and then import them into your own Wiki.

After that make the necessary edits which correspond to your Wiki, such as changing links etc.

FrugalTPH (talkcontribs)

Ah, I'm getting somewhere with this now.


I added the following to LocalSettings.php:

$wgHooks['ArticleViewHeader'][] = 'addHeaderToPages';

function addHeaderToPages( &$article, &$outputDone, &$pcache ) {
  global $wgOut;
  $wgOut->addWikiText('Template:QmsHeader');
  return true;
}

Then I created Template:QmsHeader with the following content:

<includeonly><div id="mw-QmsHeader">{{#ifeq: {{PROTECTIONLEVEL:edit}} | sysop | {{Protected}} }}</div></includeonly>

My {{Protected}} template contains an appropriately formatted mbox.

All seems to be working ok. Now I just need to see if I can pull in the "Protecting user" and "Reason" parameters to feed into as {{Protection|user|reason}} somehow too.

FrugalTPH (talkcontribs)

I've decided to just keep it simple for the protection mbox:


Reply to "Show messagebox on protected pages"