Change the width (not length) of snippet (remove br's?)

2 views
Skip to first unread message

Mike Baratta

unread,
Mar 4, 2014, 10:41:30 AM3/4/14
to Google-Search-...@googlegroups.com
Hi,

We would like bigger snippets that stretch to the width of the page. I've increased the snippet size but it only makes it taller.

 I've been trying to make the snippets wider by modifying the CSS to no avail. I've noticed that the GSA is adding <br> tags where (I guess) it feels the snippet should wrap.

I was unsuccessful in finding the portion of the XSLT where this is done, so I can remove the breaks.

Can anyone point me in the right direction?

Thanks in advance,
Mike

Mathias Bierl

unread,
Mar 4, 2014, 10:50:04 AM3/4/14
to Google-Search-...@googlegroups.com
This is done by the GSA itself and not by the XSLT.
If you look at the XML results you will see these <br> tags in the Snippet-Node of the result.

Mike Baratta

unread,
Mar 4, 2014, 11:21:03 AM3/4/14
to Google-Search-...@googlegroups.com
Arrghh. That's annoying. Not sure I see the point in that.

Thanks for the quick response.

Mike

--
You received this message because you are subscribed to a topic in the Google Groups "Google Search Appliance/Google Mini" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/Google-Search-Appliance-Help/iJ3nuuyr_YA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to Google-Search-Applia...@googlegroups.com.
To post to this group, send email to Google-Search-...@googlegroups.com.
Visit this group at http://groups.google.com/group/Google-Search-Appliance-Help.
For more options, visit https://groups.google.com/groups/opt_out.

Edwin Stauthamer

unread,
Mar 4, 2014, 12:18:17 PM3/4/14
to Google-Search-...@googlegroups.com
Here's something to help you with that:

The GSA sometimes throws in BR tags into the snippet itself (in the XML), so that it ends up leaving a lot of white space on the page and doesn't look that good.  Here is a small XSLT template along with the code that you need to change in the XSLT to call it, to remove BR tags from snippets and to replace it with a single space.

Add the following template to your XSLT:

<xsl:template name="string-replace-all">
  <xsl:param name="text" />
  <xsl:param name="replace" />
  <xsl:param name="by" />
  <xsl:choose>
    <xsl:when test="contains($text, $replace)">
      <xsl:value-of select="substring-before($text,$replace)" />
      <xsl:value-of select="$by" />
      <xsl:call-template name="string-replace-all">
        <xsl:with-param name="text" select="substring-after($text,$replace)" />
        <xsl:with-param name="replace" select="$replace" />
        <xsl:with-param name="by" select="$by" />
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$text" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Change the following lines in the XSLT where it is printing out the snippet:

          <xsl:call-template name="reformat_keyword">
            <xsl:with-param name="orig_string" select="S"/>
          </xsl:call-template>

to:

        <xsl:variable name="snippetNoBr">
          <xsl:call-template name="string-replace-all">
            <xsl:with-param name="text" select="S" />
            <xsl:with-param name="replace" select="'&lt;br&gt;'" />
            <xsl:with-param name="by" select="' '" />
          </xsl:call-template>
        </xsl:variable>

          <xsl:call-template name="reformat_keyword">
            <xsl:with-param name="orig_string" select="$snippetNoBr"/>
          </xsl:call-template>


--
You received this message because you are subscribed to the Google Groups "Google Search Appliance/Google Mini" group.
To unsubscribe from this group and stop receiving emails from it, send an email to Google-Search-Applia...@googlegroups.com.



--
Met vriendelijke groet,

Edwin Stauthamer
ed...@stauthamer.net
(+31) (0) 6 45554994

Mike Baratta

unread,
Mar 4, 2014, 1:06:52 PM3/4/14
to Google-Search-...@googlegroups.com, ed...@stauthamer.net
Thank you Edwin. That worked perfectly, and saved me the time and frustration to write something similar on my own.

Thanks again,
Mike

Miguel Rolo

unread,
Jan 27, 2015, 6:10:10 AM1/27/15
to Google-Search-...@googlegroups.com, ed...@stauthamer.net
Thanks, work perfectly
Reply all
Reply to author
Forward
0 new messages