• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Adding OpenSearch to XF


Well-known member
In order to get the Chrome "tab to search" feature working, and apparently to do similar in other browsers which support it, I'm attempting to add OpenSearch to XF.

But I've hit a snag. What I know about XML wouldn't fit into a mosquito's antennae.

From another thread here, I figured out I can do searches via GET by doing the following:

I can put that into my address bar and the search actually works fine.

It's when I get to the XML portion that I hit a snag. First, let me show you how easy it apparently is to implement OpenSearch into a page/site/whatever. This is as simple as adding a file and making one tiny template edit.

First, you need to create a proper XML document. I named mine opensearch.xml.

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>XYZ Forum</ShortName>
<LongName>Search XYZ Forum</LongName>
<Description>Search the XYZ Forums</Description>
<Developer>Joe Developer</Developer>
<Attribution>Copyright Joe Developer, Inc.</Attribution>
<Image width="16" height="16" type="image/x-icon">http://www.xyzforum.com/favicon.ico</Image>
<Url type="text/html" method="GET" template="http://forums.xyz.com/index.php?search/search&keywords={searchTerms}"/>
Then, you insert a "link rel" tag into the <head> of your document (in this case, you can add it in the PAGE_CONTAINER template):

<link rel="search" type="application/opensearchdescription+xml" title="XYZ Forums" href="/opensearch.xml" />
And that is supposed to work.

However, it seems there is a hiccup in XML. When I try loading the page in the forum, there is no change. If I click on the /opensearch.xml file when I view the page source, Chrome complains about invalid XML.


Running through a validation gives me the following:


In essence, it's the word "keywords" that must be a reserved word in XML which I cannot use.

If I can get past that, perhaps this might start working. Is anyone here familiar enough with XML that might know a workaround or edit that would make this XML pass validation?


Well-known member
Here's an example of one that works (at Cool Sci-Fi and other places that I've done at it)...

<?xml version="1.0" encoding="UTF-8"?>
        <ShortName>Cool Sci-Fi</ShortName>
        <Description>Search Cool Sci-Fi, sci-fi and fantasy discussion!</Description>
        <Url type="text/html" method="get" template="http://coolscifi.com/search/1/?q={searchTerms}&amp;o=date" />
        <Url type="application/opensearchdescription+xml" rel="self" template="http://coolscifi.com/opensearch.xml" />
        <Tags>sci-fi forums fantasy horror</Tags>
        <LongName>Cool Sci-Fi Community</LongName>
        <Image height="16" width="16" type="image/x-icon">http://coolscifi.com/favicon.ico</Image>
        <Query role="example" searchTerms="star trek" />
        <Attribution>Search data results copyright CoolSciFi.com</Attribution>

And here's the head tag...
<link href="https://coolscifi.com/opensearch.xml" rel="search" title="Cool Sci-Fi" type="application/opensearchdescription+xml" />
Last edited:


Well-known member
It works on other sites as I posted it (with a different search URL template of course), but not on XenForo. However, I think I found something in your code that will help!

Since "&" is an HTML entity, I need to write out that &amp; in my URL. Going to try that now. That explains why it is balking around the word "keyword" in the URL.



Well-known member
Sure enough, that made it work, and results come back nicely. I can see it working in Chrome, but...how can you see its results using IE or Firefox? I had no luck in IE11 seeing anything, and Firefox I don't use. If it involves downloads of plugins, then I won't bother with either one.
Last edited: