Template talk:Search link

Default output

Plastikspork: I see that you too prefer that a template have some kind of default output, even when it doesn't get the parameters it needs. I am thinking of several different possible default behaviours:

1: Currently this template outputs a search for its own template name, using the caption "search". Like this: [{{fullurl:Special:Search|search={{

urlencode:Template:Search link}}{{

#if:

| {{#ifeq: | all

| &ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1&ns10=1&ns11=1&ns12=1&ns13=1&ns14=1&ns15=1&ns100=1&ns101=1

| &{{lc:}}

}}

}}{{

#if:

| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}{{

#if:| &{{lc:}}=1

}}&fulltext=Search

}} search]

2: It could return a link to Special:Search, with the caption "search", which would look like this: search

3: Or it could show its own basic syntax, which would look like this: {{search link|search string|link text}}

I think the template should only do this when it doesn't get parameter one. If it doesn't get parameter two then it can simply use the default caption "search" as it does now.

I think I slightly prefer option three. But the other two is okay too.

--David Göthberg (talk) 11:49, 22 April 2009 (UTC)

: I was actually planning to go with option three, but I just didn't get around to it. I made a first attempt. Feel free to add indentation/comments/etc, or improve it. Thanks! Plastikspork (talk) 23:19, 22 April 2009 (UTC)

::The code looks great, you are a skilled template coder. I can't see anything to improve in the code itself. I just did a little indenting and added some words in two of the comments. And all seems to work fine. I think this template is ready to deploy!

::You should proofread the documentation, since I am not a native English speaker so I pretty often make some funny sentences. And besides, a documentation usually is not complete until 3-4 persons have worked it over. And change it to American English if that is your preference, since this is "your" template, you did all the hard work. (I just have my spell checking plug-in set to British English since that means many words are spelled more like in my native tongue Swedish.)

::--David Göthberg (talk) 02:14, 23 April 2009 (UTC)

::: Your command of the English language is exceptional. I have lived on both sides of the Atlantic, so I find myself thinking about the ENGVAR problem. Plastikspork (talk) 23:13, 23 April 2009 (UTC)

I changed the default output for the "link text" to be the "search string". I think this is as logical a choice as "search", but is keeps me from writing the same text twice on the "List of common misspellings" page. Thanks again. Plastikspork (talk) 23:13, 23 April 2009 (UTC)

:Haha, thanks. Well, I have a good spell checking plug-in in my browser. And the English and Swedish languages are pretty close, so that makes it easier.

:Oh, I like your new default. Yeah, in most cases one probably want to see the search string, not the word "search". So yeah, will save a lot of typing in cases like yours.

:And now I am curios: Why did you add whitespace stripping around parameter 1 when it is used as link text? Was it needed?

:And I am thinking, we probably want to be able to use the template like this:

::{{search link|New York| |ns0}} = {{search link|New York| |ns0}}

:That is, when parameter 2 is empty but defined, then we also want the search string to be the caption. Currently when feeding an empty but defined parameter 2 we get no caption, just a numbered link. I can fix it for you if you want it but don't know how to do it, but I think you know.

:--David Göthberg (talk) 00:16, 24 April 2009 (UTC)

:: Good idea. I believe I correctly modified it. You are correct about the added stripping of whitespace around the link text when it's set to parameter 1, it does not appear to be necessary, so I removed it. Thanks again. Plastikspork (talk) 04:34, 24 April 2009 (UTC)

:::Yes, your modification works fine. I updated the documentation accordingly.

:::And a side note: Since parameter 1 and 2 now are within an if-case when fed as link text, as a side effect they both get whitespace stripping. Not that we need it in this case, but I just wanted to mention when we get whitespace stripping.

:::--David Göthberg (talk) 10:44, 24 April 2009 (UTC)

:::: Yes, good point. Thanks! Plastikspork (talk) 14:52, 24 April 2009 (UTC)

Not for use in articles?

Similar search templates such as {{Tl|Google custom}} and {{Tl|Search subpages link}} contain warnings (both in the templates and their documentation pages) against using search links from articles. Wikipedia editors added these warnings after this discussion:

indicated the need to exclude such links from article space. To avoid a repetitive nomination for deletion, someone may want to add a similar warning to this template and its documentation. I can add the warnings if you like, but since other editors are actively developing this template I hesitate to jump in and possibly break something. --Teratornis (talk) 20:06, 29 April 2009 (UTC)

:{{done}} Thanks for the suggestion. Plastikspork (talk) 21:32, 29 April 2009 (UTC)

wildcard

Is {{search link|*wild card"}} broke? OR is {{search link|it not}}? — CpiralCpiral 21:49, 23 February 2013 (UTC)

: This is a problem with the parserfunction turning the * into a bullet. Unfortunately, I don't see any easy way to fix this at the moment, so try this {{search link|{{asterisk}}wild card"}} for now. Plastikspork ―Œ(talk) 22:46, 23 February 2013 (UTC)

:: It looks like that doesn't work either. I will work on it ... Thanks! Plastikspork ―Œ(talk) 22:56, 23 February 2013 (UTC)

::: Okay, I think I fixed it. Thanks! Plastikspork ―Œ(talk) 23:03, 23 February 2013 (UTC)

Who is Slovene?

Why does {{sl|wp:pagename}} return "(Slovene)": {{sl|wp:pagename}}? — CpiralCpiral 03:59, 5 March 2013 (UTC)

:{{In lang|sl}}? It was a language icon for external links. Now {{tl|sl}} redirects here, per Template talk:sl, because now we have

  • This template, {{tl|sl}} to directly create general search links of any and all kinds
  • {{tl|slre}} to sandbox and develop a general regexp search, then share its search link
  • {{tl|tlre}} to sandbox and develop a template regexp search, then share its search link

For why these sandboxes may be important, see mw:Help:CirrusSearch's insource:/regexp/ searches. To learn more about MediaWiki's Elastica regexp extension, see the documentation for slr and slt.

CpiralCpiral 21:42, 8 July 2015 (UTC)

Insource: doesn't work

The recommended search method, when using insource:/regexp/ (mw:Help:CirrusSearch#insource:) is to layer two or three filters, but it doesn't display:

{{#invoke:DemoTemplate|search link|insource:val insource:/\{val/ insource:/u=/}}

CpiralCpiral 19:09, 11 June 2015 (UTC)

Oh, I forgot to use either 1= or {{=}} if I have an "=" in my search link. Thanks. — CpiralCpiral 21:05, 2 July 2015 (UTC)

Insource:/regex/ without a link=label so that the text=query is the label, now works with square brackets. I edited the template after testing in the sandbox. I also edited the Advanced section of the documentation, redirected links, and removed unnecessary material, replacing it with other material. Now its more usable in its important place in the {{tl|sl}}/{{tl|slre}}/{{tl|tlre}} scheme. — CpiralCpiral 10:31, 12 July 2015 (UTC)

Proposed change for blank input

currently, when the input is blank, this template returns "documentation" in the form of the following nowiki string: {{search link|search string|link text}}. I would like change this to return a link to the page [{{fullurl:Special:Search|fulltext=Search&ns0=1&redirs=1}}] which would then allow the user to type in a search, without having it pre-filled. any comments? Frietjes (talk) 17:33, 2 December 2014 (UTC)

  • I support this. It makes sense that omitting the parameter would give a blank search box, and we already have the documentation page. —PC-XT+ 01:27, 7 December 2014 (UTC)
  • Done? Plastikspork ―Œ(talk) 02:47, 8 December 2014 (UTC)
  • yes, thank you. Frietjes (talk) 17:16, 8 December 2014 (UTC)

I must be missing something. See these tests:

  • {{#invoke:DemoTemplate|sl|text=}}
  • {{#invoke:DemoTemplate|sl}}
  • {{#invoke:DemoTemplate|sl|1=}}
  • {{#invoke:DemoTemplate|sl|text=0}}

CpiralCpiral 11:53, 12 July 2015 (UTC)

: {{search link||search}} still works. Frietjes (talk) 23:00, 21 July 2015 (UTC)

Default search domain

The default search domain is now article space. This change does not effect an IP who clicks on a search link that has no ns specified. But for logged in users who have set there own user preference for there own search domain at Special:Search Advanced, it will have a beneficial effect.

When someone creates a search link without specifying a search domain, limiting a default search domain to article space is beneficial for two scenarios: 1) the creator was unfamiliar with the intricacies of search behaviors, assumed the default search domain was article space, and did not read Help:Searching or this Template:Search link documentation, and the link they created is activated by a user who has set there default search domain to all namespaces or to any other combination of namespaces: the benefit is that it no longer loads the search engine while unnecessarily violating the creators intentions. 2) The advanced user doesn't want to have to specify the namespaces every time, no matter what, because it is a 3rd parameter, and parameter two is often unneeded, so setting the 3rd parameter requires naming it, and that opens up the writing of the search link to easy errors.

When the search link is tested by an advanced creator, they will probably notice the effected search domain, and change it accordingly if needed.

CpiralCpiral 06:43, 8 August 2015 (UTC)

Search within the pages within a WikiProject

Am trying to specifically search for a url within a specific Wikiproject. Any advice on how to do this? Doc James (talk · contribs · email) 18:09, 12 March 2017 (UTC)

:{{ping|Doc James}} I'm no expert, but I think you're looking for the "prefix" parameter. If you were looking for "test" in WikiProject Medicine, for instance, you'd type

Test prefix:Wikipedia:WikiProject Medicine
into the search box. To search the talk pages, it would be a separate search:
Test prefix:Wikipedia talk:WikiProject Medicine

:For a URL, you could enclose it in quote marks:

"http://biogeosciences.agu.org" prefix:Wikipedia:WikiProject Medicine

:I don't know that the quotation marks are necessary, but they won't hurt.

:I hope this helps. — Gorthian (talk) 16:33, 13 March 2017 (UTC)

::To clarify I want to search the content pages within a specific Wikiproject not the WP itself. Doc James (talk · contribs · email) 17:25, 13 March 2017 (UTC)

:::Ah, I think I understand: you want to search articles that are "claimed" by a certain WikiProject. The [https://petscan.wmflabs.org PetScan tool] (manual) is very powerful and configurable, BUT I don't think it searches the text of articles. Or, if it does, I don't know how to do it. — Gorthian (talk) 04:05, 14 March 2017 (UTC)

::::Okay thanks. I will keep looking. Doc James (talk · contribs · email) 04:19, 15 March 2017 (UTC)

Searching for strings that use specific capitalization

Is it possible to specify capitalization in search strings? Also, is it possible to exclude redirects from search results? (I'm a typo hunter, and have a couple of projects in mind. E.g., fixing instances of "Sig Sauer" (SIG Sauer) and "freemason".) —DocWatson42 (talk) 10:45, 6 May 2017 (UTC)

: DocWatson42, I believe "insource" is case sensitive. for example, try [//en.wikipedia.org/w/index.php?search=insource%3A%2FSIG+sauer%2F&title=Special:Search&go=Go this] vs [//en.wikipedia.org/w/index.php?search=insource%3A%2FSIG+Sauer%2F&title=Special:Search&go=Go this]. Frietjes (talk) 14:37, 4 June 2017 (UTC)

:: {{Ping|Frietjes}} That works—thank you. ^_^ —DocWatson42 (talk) 15:22, 6 June 2017 (UTC)

Option to add quote marks?

Is there an option to add quote marks automatically? [https://en.wikipedia.org/w/index.php?title=Special:Search&search=predominately&ns0=1&ns14=1&ns100=1&fulltext=Search This search], for example, results in about twice as many false positives (9,000) as useful search results (3,000) when I am looking for the actual word. [https://en.wikipedia.org/w/index.php?search=%22predominately%22&title=Special:Search&profile=advanced&fulltext=1&ns0=1&ns14=1&ns100=1 Adding quote marks] works better, but I would rather have it as an option than have to type the quote marks every time. – Jonesey95 (talk) 13:16, 20 May 2023 (UTC)