Template:Commons category: Difference between revisions

From TestWiki
Content added Content deleted
(Handle underscores (which was asked for in the original edit request that resulted in the page name encoding, but never implemented))
(New version from sandbox: using commons sitelinks, redoing tracking categories, and other changes - see Template_talk:Commons_category#Please_test_a_new_version_of_this_template for discussion.)
Line 1: Line 1:
{{Commons
{{Commons
| position = {{{position|}}}
| position = {{{position|}}}
<!-- Link -->
<!-- {{#if:x|}} strips whitespace from parameter 1,
| 1 = <!--
in case it is fed like this: {{Commons category| Some cat }}. -->
Check for a locally-specified category
|1=Category:{{#if:{{{1|}}}
|{{{1|}}}
-->{{#if:{{{1|}}} | Category:{{{1|}}} <!--
... or use Wikidata
|{{#if:{{#property:P373}}
-->|{{if then show|{{#invoke:WikidataIB |getCommonsLink|qid={{{qid|}}}|onlycat=True}}<!--
|{{#property:P373}}
... or fall back to the page name
|{{PAGENAME}}
--> |Category:{{PAGENAME}} }} }}
}}
<!-- Display title -->
}}
|2={{{2|{{{1|{{PAGENAME}}}}}}}}<!--
| 2 = {{{2|{{#if:{{{1|}}} | {{{1|}}} <!--
-->|{{if then show|{{#invoke:String|replace|{{#invoke:WikidataIB |getCommonsLink|qid={{{qid|}}}|onlycat=True}}|Category:|}}<!--
-->}}<noinclude>
--> |{{PAGENAME}} }} }} }}}
}}<!--
End of the template code, now add relevant tracking categories

--><includeonly>{{#switch:{{NAMESPACE}}||{{ns:14}}=<!--
Only add tracking categories to articles and categories.
-->{{#if:{{{1|}}}|{{#ifeq:Category:{{{1|}}}|{{#invoke:WikidataIB |getCommonsLink|qid={{{qid|}}}|onlycat=True}}|<!--
-->[[Category:Commons category link is on Wikidata]]<!--

-->|{{#ifeq:{{{1|}}}|{{PAGENAME}}|<!--
... the local parameter is the same as the local pagename, but not the same as on Wikidata
-->[[Category:Commons category link is defined as the pagename]]<!--

... the local parameter does not match either of these
-->|[[Category:Commons category link is locally defined]]}} }}<!--

We don't have a locally-defined link
-->|{{#if:{{#invoke:WikidataIB |getCommonsLink|qid={{{qid|}}}|onlycat=True}}|<!--

... so we're using Wikidata
-->[[Category:Commons category link from Wikidata]]<!--

... or we've fallen back to the pagename
-->|[[Category:Commons category link is the pagename]]}}
}} }}</includeonly><noinclude>
{{Documentation}}
{{Documentation}}
<!-- Add categories to the /doc subpage, not here! -->
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
</noinclude><includeonly>{{#if:{{{1|}}}||{{#if:{{#property:P373}}||{{#switch:{{NAMESPACE}}
|User|User talk=
|#default=[[Category:Commons category template with no category set|{{#ifeq:{{NAMESPACE}}|||{{Namespace Greek}}}}{{BASEPAGENAME}}]]<!--
-->}}}}}}<!-- Some tracking categories to see if we're ready to switch to Wikidata
-->{{#switch:{{NAMESPACE}}||{{ns:14}}=<!-- Only articles and categories.
-->{{#if:{{#property:P373}}
| {{#if:{{{1|}}}
| {{#ifeq:{{PAGENAME:{{#property:P373}}}}|{{PAGENAME:{{{1|}}}}}
| <!-- [[Category:Commons category with local link same as on Wikidata]] – deleted per [[Wikipedia:Categories for discussion/Log/2017 January 25]] -->
| [[Category:Commons category with local link different than on Wikidata]] <!-- Figure out the best link -->
}}
| {{#ifeq:{{PAGENAME:{{#property:P373}}}}|{{PAGENAME}}
| <!-- [[Category:Commons category with page title same as on Wikidata]] – deleted per [[Wikipedia:Categories for discussion/Log/2017 January 25]] -->
| [[Category:Commons category with page title different than on Wikidata]] <!-- Figure out the best link here too -->
}}
}}
| [[Category:Commons category without a link on Wikidata]] <!-- These we still need to import -->
}}
}}</includeonly>

Revision as of 20:17, 14 November 2018

Template:Commons