0

I've got a template designed to transclude content into the mainspace from a page in another namespace; it's used to aggregate a large number of pages into a single table. Its basic structure is this:

Template:Paget

<div class="plainlinks">
<span style="font-weight:normal; font-size:85%;">&#91;[{{fullurl:{{{1|}}} {{{2|}}}.{{{3|}}}}} {{{2|}}}]&#93;</span>&nbsp;{{#if: {{{blank|}}} | [No text] | {{{{{1|}}} {{{2|}}}.{{{3|}}}}} }}
</div>

So when you enter {{paget|page:cod.icon. 393 I|100r|jpg}} it transcludes the content of Page:Cod.icon. 393 I 100r.jpg and also labels it with a link back to that page that opens in a new tab. Very simple.

Aggregation pages are often constructed before all of the content exists, and in that case the template produces a redlink in place of the page content. I want to change this behavior so that it simply displays nothing when no page exists.

There are three main solutions, an {{#ifexist}} function, a {{#dpl}} function, and an {{#ifeq}} function comparing the output to a redlink url. All of these are unworkable for various reasons, but mostly because they slow the page loading way down (sometimes we're transcluding thousands of one-paragraph pages).

So I turned to a CSS solution, and created this rule in Mediawiki:Common.css:

.hidden-redlink > a.new,
.hidden-redlink a.new {
    display: none;
    visibility: hidden;
}

Then I added the class to the template, i.e. <div class="plainlinks hidden-redlink"></div>. This produced no result. I also tried wrapping just the transcluded portion in a <span class="hidden-redlink"></span>, and just adding the class to the aggregation table itself, but those also failed to produce any result. Wrapping it directly in <span style="display:none;"></span> hides the link, but obviously also hides the transcluded content.

I've rejiggered the CSS rules and class assignment every way I can think, but come up empty. Is there some piece of the puzzle I'm missing?

MediaWiki: 1.21.2
PHP: 5.3.10-1ubuntu3.9 (apache2handler)
MySQL: 5.5.29-0ubuntu0.12.04.2

Nemo
  • 2,441
  • 2
  • 29
  • 63
  • 1
    Well I can say that `.hidden-redlink a.new` matches everything that `.hidden-redlink > a.new` would, which makes the `>` selector redundant. – BoltClock Mar 02 '14 at 04:42

1 Answers1

0

Well, I tried doing something similar, getting a redlinked page through transcluding an uncreated help page by doing {{help:doesn't exist}} inside a div with class="hidden-redlink" and the following CSS worked to hide the red link:

.hidden-redlink a.new {
    display:none !important;
}

To be honest with you, I don't quite understand why you are using such a long piece of code to get your transclusions, but yet again I don't recognise that namespace you're getting your code from, so I probably just don't use the software to the level of complexity you're pushing it to. Are there any problems with transcluding using {{namespace:pagename}} (obviously changing the words namespace and pagename to the namespace and page name respectively) instead of your current long piece of code which might be throwing things out of whack?

Imamadmad
  • 77
  • 1
  • 11
  • See, for example, this article: http://wiktenauer.com/wiki/Paulus_Hector_Mair . Scroll down to "longsword", and you'll see multiple transclusions per line, and in the far right column, empty transclusions showing up as red links. (The Index and Page namespaces are used by the transcription management program, which is the same one that runs Wikisource.) – Michael Chidester Jun 22 '14 at 20:49
  • I can see, under "longsword", that you have image transclusions and article transclusions down to line 121, at which point there are more images but no more articles. However, I cannot see these red links you are describing in either Chrome, IE, or Firefox. The boxes are blank apart from the number. Could you tell me what browser you're using? – Imamadmad Jul 02 '14 at 06:39
  • Did you scroll over to the right-most column, header "Jörg Breu's Sketchbook (1545)"? I've tested it in IE 10, Firefox 24, and Chrome 6, and they all render the redlinks the same way. – Michael Chidester Jul 31 '14 at 14:18
  • Ah, no. I didn't notice the table was wider than the first 3 columns. Yes, I can see the links to the page namespace in them now. There seems to be something odd with the CSS when inspecting the page in Chrome. Have you tried adding !important to your CSS statements? That usually overrides default styling and so should hopefully do the trick here. I'll edit my original post to show how you would add the important statement. – Imamadmad Aug 20 '14 at 10:28