Copied to clipboard

Flag this post as spam?

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


  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 30, 2011 @ 15:25
    Jan Skovgaard
    0

    How to show two different search results

    Hi guys

    I'm currently thinking about what would be the best way to go about using XSLTsearch for showing two different search results on the same page.

    I have 1 search field and I need to display two search result on the same page based on the input.

    So I'm going to have results from a content section and a news section displayed. You can see what the result should be by looking at http://www.sinodanishcenter.dk/index.php?menu_id=8 and search for "news" for instance.

    I need to achieve the same thing.

    Currently I have added a parameter to the XSLTsearch macro so I'm able to select the source of the news. Now I need to figure out how this is done most easily so I'm hoping for some input and guidelines for this :)

    Thanks.

    /Jan

     

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 30, 2011 @ 15:29
    Douglas Robar
    1

    Couldn't you put the search macro on the template twice, with different parameters (for the source and also for any fields to search within unique to each section)?

    cheers,
    doug. 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 30, 2011 @ 15:54
    Jan Skovgaard
    0

    Hi Doug

    Hmm yeah I suppose that could work actually.

    My only concern is that one of the sources is the siteroot and the other is located as a child of the siteroot. Like this...

    Home
       - document
       - document
       - news document
       - document
       - etc.

    So in the case where my source is Home i don't want it to output the results for news document and it's children as well in the result. Guess I can make some comparison in XSLT to make sure that it's not included if the source is "Home".

    I will look further into it, thanks for the input so far.

    /Jan 

     

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 30, 2011 @ 16:01
    Douglas Robar
    1

    Yeah, I'd still use two macros. But perhaps duplicate the xsltsearch macro and .xslt file and modify one of them to exclude news items. Here's an old (aka, legacy xml schema) discussion on how to do that. The logic is the same in XSLTsearch v3 but you'll want to use the new xpath to achieve the same results. It's just a minor customization to ignore certain docTypes.

    http://blog.percipientstudios.com/2009/4/7/customizing-xsltsearch.aspx

    cheers,
    doug.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 01, 2011 @ 10:14
    Jan Skovgaard
    0

    Hi Doug

    Thank you very much - I should be able to finish the job from here :)

    /Jan

  • Gus Deadman 45 posts 65 karma points
    May 22, 2012 @ 11:53
    Gus Deadman
    0

    I have installed CWS Starter site with the XSLTSearch and I am now attempting to restrict the search to just the News and Events Section of the site by specifying the node types it should search. The blog linked above is very clear, however the changes suggested there didn't work for me. It is ignoring the restriction of the node type and searching everything. 

    I also noticed that variables aside, there was a slight difference in the example code and the actual code. This may due to XSLTSearch version changing between the blog and now.

    This is the restricting code I'm using in the XSLT file is;

        <xsl:variable name="possibleNodes" select="$items/descendant-or-self::node[ 

                      string(data [@alias='umbracoNaviHide']) != '1' 

                      and ( 

                      @nodeTypeAlias = 'CWS_NewsItem'

    or @nodeTypeAlias = 'CWS_EventItem'

    )

                                 and count(attribute::id)=1 

                                 and (umbraco.library:IsProtected(@id, @path) = false()

                                  or umbraco.library:HasAccess(@id, @path) = true())

                               ]"/>

    What should my next steps be?

    Gus

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    May 22, 2012 @ 15:26
    Douglas Robar
    0

    Hi, Gus,

    You've got the correct idea but the wrong XML syntax (the blog post was for the legacy xml schema in Umbraco). What you should have for the new schema is:

        <xsl:variable name="possibleNodes" select="$items/descendant-or-self::*[
                                 @isDoc
                                 and (
                                  name() = 'CWS_NewsItem'
                                  or name() = 'CWS_EventItem'
                                 )
                                 and string(umbracoNaviHide) != '1'
                                 and count(attribute::id)=1 
                                 and (umbraco.library:IsProtected(@id, @path) = false()
                                  or umbraco.library:HasAccess(@id, @path) = true())
                               ]"/>
    

    cheers,
    doug. 

     

  • Gus Deadman 45 posts 65 karma points
    May 22, 2012 @ 15:55
    Gus Deadman
    0

    Thanks for this and the swift response. I'm afraid though, it's still not confining the results to the nodes/doc-types I'm looking for.

    Although I'm quite happy editing existing files I haven't been trained in Visual Studio or WebMatrix so I'm not sure if I have done everything that is necessary to make the changes take effect.

    Is there anything else I have to do other than edit the XSLT and save it?

    Thanks

    Gus

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

    Just edit the xslt and save it, that's all that's necessary. And that can be done directly inside Umbraco so no particular need for WebMatrix or Visual Studio for this.

    The above modification will only return pages with a document type of CWS_NewsItem or CWS_EventItem. Do be sure those are the alias names associated with the document types you want to return results from. The simple way to do this is:

    1. In the Content section of umbraco, select a page you want XSLTsearch to search.
    2. Click the 'Properties' tab and you'll see the document type listed. Note this doctype.
    3. In the Settings section of umbraco, expand the document types tree and select the document type you noted above.
    4. On the 'Info' tab you'll see the Name and Alias fields. You want the Alias.
    Enter the Alias for the document type on the name()='mydoctypealias' line in the XSLT. 
    If you have multiple document types you want to search, use an 'and' as I've shown above.

    cheers,
    doug. 

  • Gus Deadman 45 posts 65 karma points
    May 23, 2012 @ 16:17
    Gus Deadman
    0

    Thanks, I've checked those things and they are as you instructed.

    It's interesting that you say I should be able to access XSLTsearch.xslt from within Umbraco as it's not in the list. This search came as part of the CWS Starter Site and the XSLTsearch.xslt file doesn't appear in the list of xslt files in the developer's section. I understood it was the XSLTsearch but maybe it's not.

    I have another umbraco site that you sent me a few weeks back where XSLTsearch was installed on a blog site and here the XSLTsearch.xslt file appears in the list of xslt files in the developer's section. I'm really quite puzzled.

    Thanks

    Gus/Andrew

     

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    May 24, 2012 @ 10:41
    Douglas Robar
    0

    Hey Gus (or is it Andrew?)

    This might more appropriately be a question for the CWS forum instead. But let's try a bit more anyway.

    Depending on which version of CWS you installed you'll have either XSLTsearch or Examine as the search engine. They are very different and could explain why you don't see XSLTsearch (in the XSLT tree of the Developer section of the Umbraco interface).

    CWS 2.x uses XSLTsearch (and XSLT macros)
    CWS 3.x uses Examine (and Razor macros) 

    Which one did you install? 

    cheers,
    doug. 

  • Gus Deadman 45 posts 65 karma points
    May 24, 2012 @ 11:02
    Gus Deadman
    0

    Ah that'll be it then. I've installed CWS 3.0.2 which explains everything. It wasn't clear to me from the documentation that XSLT was no longer used.

    Thank you for your explanations and patience, I'll have to try a different route to set it up.

    Thanks

    Cheers

    Andrew/Gus

Please Sign in or register to post replies

Write your reply to:

Draft