FAQ - Umbraco

Question
Umbraco Xsltsearch Context Unavailable Bug Fix
Answer

A common error people are experiencing with the Umbraco package called XsltSearch is the "Context: unavailable" bug, whereby search results show the "Context: unavailable" message instead of text snippet where the search query is found.

This error is officially generated when a field is entered in the "searchFields" string but not in the "previewFields" string. You should check this is not the case. Also, note that properties prefixed with an "@" sign are not allowed in the "previewFields" string so this will also cause the error.

Solution

Another cause for this error is an error in the actual XSLT coding.

  • Open up the "XSLTSearch.xslt" file in the developer section of the Umbraco backend.
  • Do an in-page search for "<xsl:template name="displayFieldText">"
  • Replace the entire template with the code below:

   <xsl:template name="displayFieldText">
     <xsl:param  name="item"/>
     <xsl:param  name="fieldList"/>

     <xsl:variable  name="fieldName">
       <xsl:value-of  select="PS.XSLTsearch:getFirstElement($fieldList, ',')"/>
     </xsl:variable>
     <xsl:variable  name="remainingFields">
       <xsl:value-of  select="PS.XSLTsearch:removeFirstElement($fieldList, ',')"/>
     </xsl:variable>

       <!-- actually print out field, if it exists and has content -->
       <xsl:if  test="count($item/*[not(@isDoc) and name()=string($fieldName)]) = 1 and string($item/*[not(@isDoc) and name()=string($fieldName)]) != ''">
         <xsl:value-of  select="string($item/*[not(@isDoc) and name()=string($fieldName)])"/>
       </xsl:if>

       <xsl:if  test="$remainingFields != ''">
         <!-- if this element does not exist, go on to the next one -->
         <xsl:call-template  name="displayFieldText">
           <xsl:with-param  name="item"  select="$item"/>
           <xsl:with-param  name="fieldList"  select="$remainingFields"/>
         </xsl:call-template>
       </xsl:if>
   </xsl:template>

  • Now save the template and reload the search page and hopefully the "Context: unavailable" error should be gone!

Thanks to "Niels van Roden" for the original posting of this fix.

If you found this information useful, please share it!


This FAQ was last updated on 21 July 2011

Contact Information

To find out more about Ava solutions you can contact us in a number of ways:
Follow Us...