Changing anchors on the search engine


This page should only be used if script asks you to manually migrate code.20230620.Web-Search-Anchor

The results anchor identifier (<a name="nav"></a>) when launching a search has changed.
To support multiple search services on the same page, the anchor identifier is now unique.

It is composed of "nav-" and a unique identifier equal to :

  • or the value of the search service identifier, if this is specified in the service parameters
  • or the unique identifier of the search service zone.

Different impacts on skin that need to be taken into account

In your XSL search service (skin/[SKIN]/services/web/pages/services/search/**/*.xsl) look for the keyword "nav" and the call to "SearchService.launchSearch".
For each hit, apply one of the migrations described below, depending on the case:

  • Replace the anchor tag with the template call. For example:

<a name="nav"/>

by

<xsl:call-template name="anchor" />
  • Replace #nav with the anchor-id variable call. For example:
<xsl:attribute name="action"><xsl:value-of select="resolver:resolve('page', /search/result-page)"/>#nav</xsl:attribute>

by

<xsl:attribute name="action"><xsl:value-of select="resolver:resolve('page', /search/result-page)"/>#<xsl:value-of select="$anchor-id" /></xsl:attribute>

......

<form action="{$site-uri-prefix}/{/search/url}#nav" >

by

<form action="{$site-uri-prefix}/{/search/url}#{$anchor-id}" >
  •  Replace anchor js calls. For example:
$j('a[name=nav]')

by

$j('a[name=<xsl:value-of select="$anchor-id" />]')
  • Add the anchor identifier to the JS search. For example:
SearchService.launchSearch({
...
anchorId: "<xsl:value-of select="$anchor-id"/>",
...
});
Back to top