[MediaWiki-l] Pass category into template

Bri dev at rlyehable.com
Fri Feb 3 13:19:00 UTC 2017


Thanks for your help.


On 2017-02-03 01:27, Brian Wolff wrote:
> On Fri, Feb 3, 2017 at 2:47 AM, Bri <dev at rlyehable.com> wrote:
>> I recently upgraded to 1.28.
>> Before the update I could pass a category into a template:
>>
>> <includeonly>{|
>> |align="center"|Also see [[{{#if: {{{term|}}}|{{{term}}}|{{{1}}}| }}]]
>> |}</includeonly>
>>
>> But now it fails if I pass "Category:Foo" or ":Category:Foo".
>>
>> In the first case (with term=) it tries to assign the category to the page
>> the template is on.
>> In the second case it fails at the colon.
>> I have tried using : and making a template:colon that returns : --
>> both failed.
>>
>> I feel that I am missing something simple, but can't figure it out.
>>
>> -Bri
>>
>>
>>
>> _______________________________________________
>> MediaWiki-l mailing list
>> To unsubscribe, go to:
>> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
> #if introduces a newline in certain circumstances, which causes
> problems. However you don't even need it in your example. Try:
>
> <includeonly>{|
> |align="center"|Also see [[{{{term|{{{1}}}}}}]]
> |}</includeonly>
>
> which should fix the issue.
>
>
> If you were doing a more complicated example that actually needed the
> #if, you could also try putting the : outside the variable:
>
> <includeonly>{|
> |align="center"|Also see [[:{{#if: {{{term|}}}|{{{term}}}|{{{1}}}}}]]
> |}</includeonly>
>
> (I'm not really sure why the above works. I think the newline gets
> suppressed if the previous line ends in a word character or something)
>
> If you really didn't want to force a : to always be there, the last
> option is to move the brackets inside the clauses of the #if:
>
> <includeonly>{|
> |align="center"|Also see {{#if: {{{term|}}}|[[{{{term}}}]]|[[{{{1}}}]]}}
> |}</includeonly>
>
> Hope that helps.
>
> --
> Brian
>
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l





More information about the MediaWiki-l mailing list