Jump to content

Template:Search link: Difference between revisions

From Fifth Empire Wiki
improve the way it defaults even more: any of the 17 positional parameters can avoid a default
remove mainspace restrictions, per wt:External links; add a new limit parameter to specify how many search results are wanted
Line 1: Line 1:
{{main other
<span class="plainlinks">[{{fullurl:Special:Search|search=<!--
| 1={{Warning|{{tl|Search link}} should not be used in [[WP:WIAA|articles]] as links to "search result pages" are among the [[WP:LINKSTOAVOID|links normally to be avoided]].}}
| 2=<span class="plainlinks">[{{fullurl:Special:Search|search=<!--
     -->{{urlencode:{{{query|{{{text|{{{1|}}}}}}}}}}}<!--  Given query  
     -->{{urlencode:{{{query|{{{text|{{{1|}}}}}}}}}}}<!--  Given query  
    -->{{#if:{{{limit|}}}|&limit={{{limit|}}}}}<!--
     -->{{#if:{{{ns|}}} {{{3|}}} {{{4|}}} {{{5|}}} {{{6|}}} {{{7|}}} {{{8|}}} {{{9|}}}{{{10|}}} {{{11|}}} {{{12|}}} {{{13|}}} {{{14|}}} {{{15|}}} {{{16|}}} {{{17|}}} {{{18|}}} {{{19|}}} {{{20|}}}
     -->{{#if:{{{ns|}}} {{{3|}}} {{{4|}}} {{{5|}}} {{{6|}}} {{{7|}}} {{{8|}}} {{{9|}}}{{{10|}}} {{{11|}}} {{{12|}}} {{{13|}}} {{{14|}}} {{{15|}}} {{{16|}}} {{{17|}}} {{{18|}}} {{{19|}}} {{{20|}}}
       |  <!-- either ns or 3-20 has a value set-->
       |  <!-- either ns or 3-20 has a value set-->
         {{#if:{{{ns|}}}  <!-- is ns set? -->
         {{#if:{{{ns|}}}  <!-- is ns set? -->
         | {{#ifeq: {{{ns}}} | all    <!-- Yes. Is the value "all"?
         | {{#ifeq: {{{ns}}} | all    <!-- ns is set. Is the value "all"?
           -->| <!-- True, the value of ns is "all" -->
           -->| <!-- True, the value of ns is "all" -->
           &ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1<!--
           &ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1<!--
Line 13: Line 12:
           -->&ns711=1&ns828=1&ns829=1&ns2300=1&ns2301=1&ns2302=1&ns2303=1<!--
           -->&ns711=1&ns828=1&ns829=1&ns2300=1&ns2301=1&ns2302=1&ns2303=1<!--
           -->&ns2600=1
           -->&ns2600=1
           | <!-- No but ns is set to something -->
           | <!-- ns is set, but the value is not "all" -->
           &{{lc:{{{ns}}}}}  <!-- Add the & part here, and ns argument
           &{{lc:{{{ns}}}}}  <!-- You saw the & added, and ns argument:
                                 such as to get &ns5=1
                                 ns=ns5 gives &ns5=1
                                 Use {{lc:}} not only to lower case,
                                 Use {{lc:}} not only to lower case,
                                 but also to strip away whitespace -->
                                 but also to strip away whitespace -->
         }}
         }}
         }}{{
         }}{{
         #if:{{{3|}}}  <!-- 3 = ns0 (or any other nsX) -->
         #if:{{{3|}}}  <!-- positional parameter 3 = "ns0" or other nsX -->
         | &{{lc:{{{3|}}}}}=1  
         | &{{lc:{{{3|}}}}}=1  
         }}{{
         }}{{
Line 80: Line 79:
   -->|]|&#93;}}<!-- ] with its html symbol
   -->|]|&#93;}}<!-- ] with its html symbol
    
    
   -->]</span>
   -->]</span><!--
}}<!-- End of template main
Output a hidden category: -->{{#if: {{{ns|}}}{{{3|}}}{{{4|}}}{{{5|}}}{{{6|}}}{{{7|}}}{{{8|}}}{{{9|}}}{{{10|}}}{{{11|}}}{{{12|}}}{{{13|}}}{{{14|}}}{{{15|}}}{{{16|}}}{{{17|}}}{{{18|}}}{{{19|}}}{{{20|}}}
Output a hidden category: -->{{#if: {{{ns|}}}{{{3|}}}{{{4|}}}{{{5|}}}{{{6|}}}{{{7|}}}{{{8|}}}{{{9|}}}{{{10|}}}{{{11|}}}{{{12|}}}{{{13|}}}{{{14|}}}{{{15|}}}{{{16|}}}{{{17|}}}{{{18|}}}{{{19|}}}{{{20|}}}
  | [[Category:Search link templates with namespace parameters]]
  | [[Category:Search link templates with namespace parameters]]

Revision as of 23:38, 29 January 2016