Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Hammer 41 posts 67 karma points
    May 19, 2014 @ 13:43
    David Hammer
    0

    Show specific properties in XSLT Search

    Hey guys,

    I have XSLT search on my site. At current, it only shows the title and description of my results.

    This is my macro call in my template:

    <form>
        <umbraco:Macro runat="server" Alias="XSLTsearch"
          macroAlias="XSLTsearch"
          source="3771"
          searchFields="magazineTags, homepageArticleTags,magazineTitle,homepageArticleTitle"
          previewFields="homepageArticleBodyText,magazineTeaser"
          previewType="beginning"
          searchBoxLocation="none"
          resultsPerPage="10"
          previewChars="500"
          showPageRange="0"
          showOrdinals="0"
          showScores="0"
          showStats="0">
        </umbraco:Macro>
    </form>
    

    I've tried to put more properties in my "previewFields" but with no success. I would like my results to show:

    Title (homepageArticleTitle) - This it already shows. Date (homepageArticleDate) Teaser (homepageArticleTeaser) Description (homepageArticleBodyText - This it already shows.

    Can this be done? Is there a smart way to incooporate more properties into the results? Thank you very much up front. Anything helps!

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    May 19, 2014 @ 14:57
    Douglas Robar
    0

    Hi, David,

    The previewFields parameter is a list of fields to look for, but XSLTsearch will only show the first one that has content in it. That way, a teaser could display for magazine articles but for an event page that doesn't have a teaser field you could display a 'summary' field for instance. The previewFields parameter doesn't mean it shows all of the field, just the first one that is present and has a value.

    To change what XSLTsearch outputs, you'd need to update the xsltsearch.xslt file for your specific needs.

    Note: if you're not overly familiar with XSLT you might consider using ezSearch instead. This is the razor version of XSLTsearch and does all the same things (and a few additional things as well). Use whichever package is easier for you to work with from a coding perspective.

    cheers,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft