Topic on Project:Support desk

Template parameters in galleries

3
Summary by Bawolff

use #tag

153.96.98.7 (talkcontribs)

I am trying to create a navigation menu with addresses based on a template parameter. For this I created a gallery of icons, whose link address is calculated by passing a template parameter to a different template, which turns a given file path into a link in MediaWiki markup. However, this does not appear to work. I tried to place the parser functions of the second template into the first one directly, but that did not help at all. Placing the intended link into the gallery or the value of the parameter into the parser function work.

This is the markup:

<!-- First Template -->
<gallery mode="packed-hover" caption="Dokumente>
Image:image.png|link=file://netdata1/... <!-- this works -->
Image:image.png|link={{#if: \\netdata1\... | file:{{#replace: {{#replace: \\netdata1\...| |%20}} |\|/}} | No link!}} <!-- this works too -->
Image:image.png|link={{#if: {{{Ordner|}}} | file:{{#replace: {{#replace: {{{Ordner|}}}| |%20}} |\|/}} | No link!}} <!-- this does not work when used in an article -->
Image:image.png|link={{unc_raw | {{{ANKO-Folien|}}} }} <!-- neither does this -->
</gallery>

<!-- Second Template (unc_raw) -->
<includeonly><onlyinclude>
{{#if: {{{1}}} |file:{{#replace:{{#replace:{{{1}}}| |%20}} |\|/}} | No link!}} <!-- appends "file:" and replaces spaces with %20 and "\" with "/" -->
</onlyinclude><includeonly>

The third and fourth link always evaluate to "No link!" when I use the template. If I use the unc_raw outside of the gallery, it evaluates properly. I do not understand MediaWiki enough to have a concrete idea what is going on here.

Bawolff (talkcontribs)

You may have to use syntax like

{{#tag:gallery|
File:Example.png{{!}}{{#if:{{{a|}}}|A|not a}}
File:Example.svg{{!}}Another image
|mode=packed-hover|caption=foo|
}}

If you want to use parser functions inside gallery tags.

153.96.98.7 (talkcontribs)

Thanks, that solved the problem.