Copied to clipboard

Flag this post as spam?

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


  • wildlife 54 posts 74 karma points
    Jan 23, 2011 @ 17:19
    wildlife
    0

    Extending Locator package to search multiple document types?

    I currently have the Locator package working to display events.  However, we have made changes to the site where we now have three different event types as separate document types.  I would like the locator search to show results of all three document (event) types.

    Currently the code for executing the macro is defined as follows:

    <umbraco:Macro XPath="/root/descendant::node [@nodeTypeAlias = 'EventItem']" LocationAlias="locator" UseAddress="0" AddressAliases="" ResultsXslt="LocatorResults.xslt" AddressExtra="" UnitInKm="0" MultipleResultsCaption="" Alias="Locator" runat="server"></umbraco:Macro> 

     

    I just wanted to see what the syntax would be (if possible) to make it search three different document types.  Instead of searching only for 'EventItem', I would also like it to search for 'RegionalEventItem' and for 'CountyEventItem' document types.  Is that doable?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 23, 2011 @ 17:37
    Jan Skovgaard
    0

    Hi wildlife

    Is the Event holder node only listing the three different event types or does it have other document types like textpages etc. listed under it as well? Otherwise I think that it's really just a matter of removing [@nodeTypeAlias = 'EventItem']

    If the holder node contains many different document types, try writing this: [@nodeTypeAlias = 'EventItem'][@nodeTypeAlias = 'OtherEventitemOne'][@nodeTypeAlias = 'OtherEventItemTwo']...I think this should work...otherwise this should work: [@nodeTypeAlias = 'EventItem' and @nodeTypeAlias = 'EventItemTwo' and @nodeTypeAlias = 'EventItemThree']

    /Jan

  • wildlife 54 posts 74 karma points
    Jan 24, 2011 @ 05:37
    wildlife
    0

    Thanks for the reply.  I tried all of those, but it still didn't produce any results showing Regional Events and County Events.  I'm thinking that I might need to change this part of the code in some way:

    XPath="/root/descendant::node 

    Note that the folder structure of the site is as follows:

    Homepage folder

    • Events folder - Year folders - Month folders - Event Items
    • Regional Events folder - Region Name folders - Year folders - Month folders - Regional Event Items
    • County Events folder - County Name folders - Year folders - Month folders - County Event Items

    I have search forms on all pages that have lists of the various events where people can do a proximity search for events near them.  So for a page in the Events folder to find Regional Events, it would have to look in a different folder area within the site.  I was thinking /root/descendent::node would find them all, but maybe that just takes it back to the main Events folder, for example, instead of back to the root folder of the entire site.  I'm not sure as I'm extremely inexperienced with XSLT.  But I know the search must be conducted sitewide, not just in the folder area the current page may reside in. 

    Does the /root/descendent::node code have to be changed to find nodes anywhere in the entire site?

    Actually, I just did a test using a search form from the main Regional Events page, and the results it showed still only used the initial eventItem document alias/type.  So it is still only looking for the one event type.

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 24, 2011 @ 08:56
    Jan Skovgaard
    0

    Hi Wildlife

    Which version of Umbraco are you using? If it's 4.5.x or later then it does probably not return anything since the XML schema has changed.

    Then the code should maybe read this: root/descendant::*[@IsDoc]...

    /Jan

  • wildlife 54 posts 74 karma points
    Jan 24, 2011 @ 23:25
    wildlife
    0

    No, this site is still on 4.0.3.

  • wildlife 54 posts 74 karma points
    Jan 25, 2011 @ 11:11
    wildlife
    0

    The strangest thing is I just tried changing it to:

    <umbraco:Macro XPath="/root/descendant::node [@nodeTypeAlias = 'CountyEventItem']" LocationAlias="locator" UseAddress="0" AddressAliases="" ResultsXslt="LocatorResults.xslt" AddressExtra="" UnitInKm="0" MultipleResultsCaption="" Alias="Locator" runat="server"></umbraco:Macro>
    I did that just to see if I could get any county events to show up in the results at all, and that STILL showed only the statewide events (eventItem).  I'm now completely baffled by this and back to discouraged that this may be much more difficult to solve than I was expecting.  I was thinking it would just be a matter of changing this code in where the macro gets called.
    Something else must be in the coding somewhere that is bringing the regular eventItem nodeTypeAlias in as what is being returned in the results.
  • wildlife 54 posts 74 karma points
    Jan 25, 2011 @ 11:45
    wildlife
    0

    OK, I figured out another place where this must be changed.  The reason it still showed eventItem on the above test is there is additional code in a macro that is on the Locator Results page that filters by nodeType.  I was able to get that to change what displays on the results page among any of the three event types, but I was not able to get it to display more than one event type.  I could change among 'EventItem' 'CountyEventItem' and 'RegionalEventItem' and it would display the results as I wanted them to appear.  But I couldn't get it to work using more than one nodeType.  I'm sure this is due to a syntax issue.

    The macro code displaying the results on the Location Results page is as follows:

    <div umb_locationalias="locator" umb_useaddress="0" umb_unitinkm="0" umb_macroalias="Locator" umb_xpath="/root/descendant::node\r\n[@nodeTypeAlias = 'EventItem']" ismacro="true" umbversionid="[removed in case including this is a security problem]" umbpageid="1331" onresizestart="return false;" title="This is rendered content from macro" class="umbMacroHolder"><!-- startUmbMacro --><span>This macro does not provides rendering in WYSIWYG editor</span><!-- endUmbMacro --></div>

     

    So if I could get the correct syntax to use in place of

    umb_xpath="/root/descendant::node\r\n[@nodeTypeAlias = 'EventItem']"

    that would show all three document types in the results here, that would likely solve it.

     

     

Please Sign in or register to post replies

Write your reply to:

Draft