Page 1 of 1

Display site icon in results?

Posted: Fri May 27, 2016 1:57 pm
by munoz
My search covers different URLs, and I would like to display the URLs icon in the results.

Similar to this:
https://duckduckgo.com/?q=testing&ia=meanings

Display site icon in results?

Posted: Fri May 27, 2016 3:07 pm
by mark
The walker doesn't record site favicons. You could use XSL results style and modify the style sheet to grab the favicon directly from each site.

Display site icon in results?

Posted: Tue May 31, 2016 8:55 am
by munoz
Yeah, that might be good.
Could you maybe guide me to how do do that?
A reference page or something?

Display site icon in results?

Posted: Tue May 31, 2016 5:42 pm
by mark
Something like this will construct the img tag for favicon.ico:

<img height="16" width="16" alt="">
<xsl:attribute name="src">
<xsl:value-of select="substring-before(Url,'://')"/>
<xsl:text>://</xsl:text>
<xsl:choose>
<xsl:when test="substring-before(substring-after(Url, '://'),'/')=''">
<xsl:value-of select="substring-after(Url, '://')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-before(substring-after(Url, '://'),'/')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>/favicon.ico</xsl:text>
</xsl:attribute>
</img>

You'll probably want to add that somewhere in the ResultTitle template.

Display site icon in results?

Posted: Wed Jun 01, 2016 10:24 am
by munoz
Oh thank you!!!! That works!!!

For most of the URLS, and of course I have one where the ico is not in the root.
How can I add something to address that?

The .ico is under "URL/wp-content/themes/nabsd/"

(I have never used .xsl before in my life, so all this is new to me)

Display site icon in results?

Posted: Wed Jun 01, 2016 10:54 am
by mark
You'd have to compare Url to your prefix and do different behavior based on match/nomatch. Something like below (untested) before <xsl:text>/favicon.ico</xsl:text>

<xsl:if test="contains(Url,'/wp-content/themes/nabsd/')">
<xsl:text>/wp-content/themes/nabsd</xsl:text>
</xsl:if>

A handy XSL reference is http://www.w3schools.com/xsl/