Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Jul 06, 2012 @ 15:19
    Bo Damgaard Mortensen
    0

    Using uQuery.GetMembersByXPath() to search through members

    Hi all,

    I'm trying to get my head around an xpath expression to search find a member in Umbraco where a custom property is equal to the searchstring entered by the user.

    Thing is, I'm totally stuck when it comes to writing an xpath expression for it. I've tried the following:

    var member = uQuery.GetMembersByXPath("//*/website = 'mysite.com').FirstOrDefault();

    .. where "website" is my custom property on the member. However, this doesn't return anything. Am I missing something? :-)

    Thanks in advance!

    All the best,

    Bo

     

  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Jul 06, 2012 @ 15:20
    Bo Damgaard Mortensen
    0
    var member = uQuery.GetMembersByXPath("//*/website = 'mysite.com').FirstOrDefault();

    Should of course be:

    var member = uQuery.GetMembersByXPath("//*/website = 'mysite.com'").FirstOrDefault();
  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Jul 06, 2012 @ 15:51
    Bo Damgaard Mortensen
    1

    Managed to fix it with help from Chriztian Steinmeier and Lee Kelleher, the XPath should be like this:

    var member = uQuery.GetMembersByXPath("//*[website = 'mysite.com']").FirstOrDefault();

     

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    Jul 06, 2012 @ 16:00
    Hendy Racher
    0

    Hi Bo,

    You beat me to the answer here :) I'll update the documentation with some examples.

  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Jul 06, 2012 @ 16:16
    Bo Damgaard Mortensen
    0

    Hi Hendy,

    Updating the documentation for this method would be great! :-) Thanks a lot!

  • Gordon Saxby 1347 posts 1608 karma points
    Jul 13, 2012 @ 10:50
    Gordon Saxby
    0

    Any ideas why this doesn't work?

    var m = uQuery.GetMembersByXPath(string.Format("//*[authToken = '{0}']", rc)).FirstOrDefault();

    The string formats to

    "//*[authToken = 'zwbF3}X7']"

    That is the correct property name and that is the correct code, but GetMembersByXPath returns null.

  • Gordon Saxby 1347 posts 1608 karma points
    Jul 13, 2012 @ 12:28
    Gordon Saxby
    0

    It is because the member, created by a UserControl is present but not visible (not in the cache?). If I manually save the member in the Umbraco Admin and then run the above it works fine...

    So I just need to find out how to programmatically "save" or publish the new member!?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies