Copied to clipboard

Flag this post as spam?

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


  • Halldór Hrafn Gíslason 30 posts 50 karma points
    Sep 02, 2010 @ 11:41
    Halldór Hrafn Gíslason
    0

    Member customized public profiles with nice urls

    Hi,

    I'm looking for a way to allow for public user profiles with a nice URL, for example: www.mysite.com/john

    I'm thinking that I should perhaps somehow inject an event listener (or url rewrite rule) so that when a page request arrives and a search for an Umbraco pages comes up empty, it would then look for user profiles (with userdifend names or something) before resulting in a 404.

    Am I on the right track here? or am I a) makeing this too complicated and/or b) there is allready a way/solution/package that solves this nicely.

    I think I would rather like this to be a dynamic thing, rather than a actual page. Due to a high volume of members... right?

    Any help, tips and directions would be appreciated.

    Thanks.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 02, 2010 @ 12:12
    Ismail Mayat
    0

    You could create an event handler on new member creation and create a blank page for them with their first name and the template for that page displays data for currently logged in user.

    Regards

    Ismail

  • Halldór Hrafn Gíslason 30 posts 50 karma points
    Sep 02, 2010 @ 12:21
    Halldór Hrafn Gíslason
    0

    But how would that provide me with a custom nice URL? Would'n I also be creating a page node, wich would mess up my tree?

    /jack-> shows the puiblic profile for Jack
    /jill -> show the public profile for Jill

    typical solution is ofther a page behind that recives the request via query string through url-rewrite.

    /jack would actually be sent to /profile.aspx?id=jack

    But what would be the most practical thing here, while not messing things up for Umbraco ?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 02, 2010 @ 12:29
    Ismail Mayat
    0

    The page name would be persons name so http://somesite/jack though you would need to mess around it more than one jack best way would be Url rewrite page with query but i would use guid of member as the query string parameter and then in code do new Member(guid) that way if you have more than one jack you dont have issue.

    Regards

    Ismail

  • Halldór Hrafn Gíslason 30 posts 50 karma points
    Sep 02, 2010 @ 15:13
    Halldór Hrafn Gíslason
    0

    I'm sort of looking for a way to either auto generate unique Nice URLs from the user's name, or allow the user to make up their own (wich would check for collitions).

    I guess my question is becoming; how would I create a url-rewrite rule (or similar mechanism, if availale in Umbraco) that grabs the requested url and translate into a query string and sends to a Umbraco page (that would use the same templates and features as all other pages in Umbraco).

    Thanks, for the input so far though..

  • Sascha Wolter 615 posts 1101 karma points
    Sep 09, 2010 @ 23:20
    Sascha Wolter
    0

    Hi Halldor,

    I basically did the same thing on one of my last sites. If you go to

    http://www.consumersinternational.org/our-members/member-directory/ACA%20-%20Albanian%20Consumers%20Association%20-%20Shoqata%20e%20Konsumatorit%20Shqiptar

    you will see a page with the member information, yet that page doesn't exist as such, it is a generic member details page that takes the name of the member as parameter with a custom Url rewrite rule:

                    <add name="memberrewrite" 
                        virtualUrl="^~/our-members/member-directory/(.*)"
                        rewriteUrlParameter="ExcludeFromClientQueryString"
                        destinationUrl="~/our-members/member-directory/member?name=$1"
                        ignoreCase="true" />

    In the case of members you can easily get the member by name instead of id.

    Hope that makes sense and helps,

    Sascha

  • Halldór Hrafn Gíslason 30 posts 50 karma points
    Sep 10, 2010 @ 00:23
    Halldór Hrafn Gíslason
    0

    Thank you Sascha, this is pretty much what I was looking for (including the confirmation of a working solution) !

  • Sascha Wolter 615 posts 1101 karma points
    Sep 10, 2010 @ 00:37
    Sascha Wolter
    0

    Fantastic, glad I could help out. :)

  • FarmFreshCode 225 posts 422 karma points
    May 12, 2011 @ 19:10
    FarmFreshCode
    0

    @Sascha Wolter
    I'm having a little bit of difficulty following your example above. I'm trying to do the exact same thing tho.

    Currently my members have a page that displays all of their info and the URL looks like this:

    http://localhost/home/directory?id=1636

    but I would like for them too look like this:

    http://localhost/home/directory/John-Doe

    where (John-Doe) is the members name (John Doe). I would also like to have a (-) replace any spaces that occur within the name.
    Currently I have tried following your example and have used this code:

    <add name="memberrewrite"
               redirect="Application"
               virtualUrl="^~/home/directory\?id=(.*)"
               rewriteUrlParameter="IncludeQueryStringForRewrite"
               destinationUrl="~/home/directory/member?name=$1"
               ignoreCase="true" />

    But that just produces a URL that looks like this:

    http://localhost/home/directory/member?name=1636

    This URL also directs me to a 404 error page. Im not sure if I have something set up wrong but I have reviewed the UrlRewritingNet20.pdf and my web.config file looks to be all correct. Do you have any suggestions or solutions that might be helpful with this issue? I'm new to UrlRewriting so I may be missing something simple.

    Thank you in advance!

  • Jamie Howarth 306 posts 773 karma points c-trib
    May 12, 2011 @ 19:20
    Jamie Howarth
    0

    Hi FarmFresh,

    This will create a rewrite from /home/directory/John-Doe to /home/directory/member?name=John-Doe :

    <add name="memberrewrite"
               
    redirect="Application"
               
    virtualUrl="^~/home/directory/([^\n]+)"
               
    rewriteUrlParameter="IncludeQueryStringForRewrite"
               
    destinationUrl="~/home/directory/member?name=$1"
               
    ignoreCase="true" />

    It's then up to you to write a macro to pick up the "name" querystring and retrieve the appropriate member. Hope this makes sense?
    This is why it may be more appropriate to keep the member ID somewhere in the URL so you don't end up with the possibility of duplicate names - and subsequently, a bug when you go to a given profile URL.

    Best,

    Benjamin

Please Sign in or register to post replies

Write your reply to:

Draft