Copied to clipboard

Flag this post as spam?

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


  • Rob Watkins 343 posts 593 karma points
    Feb 13, 2012 @ 14:31
    Rob Watkins
    0

    urlName for members

    Hi, if I call umbraco.library:GetMember(id) in XSLT one of the attributes is @urlName.

    I would like to use this to key the member in a macro, by writing my own extension function that returns the member matching the urlName. Trouble is, the Member object doesn't have a urlName property and I can't work out how to create it to match the search - any ideas?

  • Rodion Novoselov 694 posts 859 karma points
    Feb 13, 2012 @ 14:43
    Rodion Novoselov
    0

    Hi. It's true - the urlName of a member is in fact unavailable when using the Member class API. Perhaps you can use some sort of a hack - the source code reveals that this urlName is formed by removing all spaces from the member name and lowercasing it than.

  • Rob Watkins 343 posts 593 karma points
    Feb 13, 2012 @ 14:46
    Rob Watkins
    0

    Hmmm, I'd be happy with that - I don't have a copy of the source at the moment, I don't suppose you could post the code for creating the urlName so I can duplicate it exactly could you?

  • Rodion Novoselov 694 posts 859 karma points
    Feb 13, 2012 @ 14:54
    Rodion Novoselov
    0

    This is exactly how umbraco does it:

    this.Text.Replace(" ", "").ToLower()

    (The "this" refers to an instance of the Content class which the Member class inherits).

  • Rob Watkins 343 posts 593 karma points
    Feb 13, 2012 @ 14:56
    Rob Watkins
    0

    Wow, I just assumed you were simplifying it, that looks like it could generate issues aplenty - duplicates? Odd characters?

    Ah well thankyou! 

  • Rob Watkins 343 posts 593 karma points
    Feb 13, 2012 @ 15:02
    Rob Watkins
    0

    Hmmm, that won't work if the member name contains ampersands (the members are companies, in this instance); looks like that urlname thing is an old hangover no longer used, because the content one is cleverer than that. I think I'll just create my own URL friendly keying system.

  • Rodion Novoselov 694 posts 859 karma points
    Feb 13, 2012 @ 15:08
    Rodion Novoselov
    0

    Well, may I ask you - how are you going to use this urlName?

  • Rob Watkins 343 posts 593 karma points
    Feb 13, 2012 @ 15:14
    Rob Watkins
    0

    The members for this site are company records; companies can log on and view various protected documents and things from their area, but they also appear in a directory that is visible to the public.

    I am creating a macro to display details for a request company; I would like to be able to use it with a readable URL like /directory/my-company - so I need to be able to look up on the company name.

    However, litterally as I was typing that you made me think; in order to absolutely guarantee uniqueness the easiest thing to do would be to append the member ID, like /directory/1011-my-company and I can use the URL rewrites to get the ID. Still a little bit ugly though.

    If you have any better suggestions then please feel free :o)

  • 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