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
    Dec 03, 2013 @ 09:55
    David Hammer
    0

    Display Property instead of nodeName

    Hi there.. I'm sorry if there is already a thread out there with an answer to this.. I've searched and searched, but have gotten no results :(

    I am looking for a way to change the display in my search results.

    I have the correct searchFields and previewFields set up for my needs, and the results works in the correct manner, but I need to do 1 thing. Right now it displays my content article/magazine name / the node's name, but I want it to show the first property the article/magazine has which is "homepageArticleTitle" and "magazineTitle".. How do I do this?

    I've been playing around with razor for some time now, but not with XSLT very much.. So if you can help me it is much appreciated :-)

    Ask me for anything, if something isn't clear ;)

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Dec 03, 2013 @ 10:23
    Chriztian Steinmeier
    0

    Hi David,

    Locate the following in the XSLTsearch.xslt file:

    <!-- page name and url -->
    <a href="{umbraco.library:NiceUrl(@id)}" class="xsltsearch_title">
      <xsl:value-of select="@nodeName"/>
    </a>
    

    and change it to this:

    <!-- page name and url -->
    <a href="{umbraco.library:NiceUrl(@id)}" class="xsltsearch_title">
        <xsl:value-of select="homepageArticleTitle" />
        <xsl:value-of select="magazineTitle" />
        <!-- Fallback to nodeName if necessary -->
        <xsl:if test="not(normalize-space(homepageArticleTitle)) and not(normalize-space(magazineTitle))">
            <xsl:value-of select="@nodeName" />
        </xsl:if>
    </a>
    

    Provided your documents have either homepageArticleTitle or magazineTitle this will work fine - if your document has both, you'll need a little extra checking - let me know if that's the case.

    /Chriztian

  • David Hammer 41 posts 67 karma points
    Dec 10, 2013 @ 13:24
    David Hammer
    0

    Sorry, I haven't responded before this time. It works great, and I very much appreciate your time!

    HIGHFIVE

Please Sign in or register to post replies

Write your reply to:

Draft