Copied to clipboard

Flag this post as spam?

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


  • Mike McCullough 54 posts 67 karma points
    Jul 24, 2009 @ 22:52
    Mike McCullough
    0

    Looking for help with Member profiles for community system

    Hi fellow umbracians,

    Looking for some clues to creating an online community Umbraco application.

    Specifically I need help with converting a member profile into an actual visible page.

    For example:

    http://site.com/profile/mike.aspx ;

    http://site.com/profile/mike (directory friendly url)

    Is this done by creating a custom URL re-writer? XSLT? Usercontrol?  I'm on a mission and would be more than happy to share my code as a result of any help.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 24, 2009 @ 23:19
    Dirk De Grave
    0

    Hi Mike,

    How did you configure umbraco/iis for that site? Is it configured to use directory urls already? If so, then you're set, no more changes!

    Do you want some code sample on how to create that 'mike.aspx' page using the api? Check these wiki pages

     

    If you'd like to go for the directory urls solution, here's a thread that might be of great help. (Look for Roel's answer)

     

    Cheers,

    /Dirk

  • Mike McCullough 54 posts 67 karma points
    Jul 25, 2009 @ 01:54
    Mike McCullough
    0

    Hi Dirk,

    I'm not using wild card mapping yet since I'm still in development (i use this on most my sites and it works great!).  I think the one feature that Umbraco needs is easy to setup Member Profile pages.

    It looks like it's built in:

    404handlers.config has this:

    <notFound assembly="umbraco" type="SearchForProfile"/>

    web.config has this:

      <add key="umbracoProfileUrl" value="profiles.aspx" />

    So I'm wondering if Umbraco automatically handles urlrewriting for Member names.

    For example:

    http://site.com/profiles/membername.aspx (which isn't a document in the content tree but auto generated)

    Just was hoping someone has done this already.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 25, 2009 @ 09:16
    Morten Bock
    1

    Hi Mike

    our.umbraco.org actually uses that feature. What happens here is that the umbracoProfileUrl is set to "member". Then there is a page in the content section called "member" that has a macro on it. When you visit the url /member/1234, in this macro you get the member id like this:

    <xsl:variable name="memId" select="umbraco.library:GetHttpItem('umbMemberLogin')"/>

    And then you can get member info like this:

    <xsl:variable name="mem" select="umbraco.library:GetMember(number($memId))"/>

    Of course, this uses the ID of the member, but I imagine that if you write /member/mike then your would get the membername in the httpitem. Then you would have to do you own lookupof the member since there is not an xslt extansion for it at the moment. Look for this method:

    Member.GetMemberByName(string usernameToMatch, bool matchByNameInsteadOfLogin);

     

     

     

  • Mike McCullough 54 posts 67 karma points
    Jul 25, 2009 @ 17:45
    Mike McCullough
    0

    Hi Morton,

    That's exactly what I needed!

    I also found this post to be very helpful http://umbraco.org/documentation/books/not-found-handlers/the-standard-umbraco-not-found-handlers

    The line <xsl:variable name="memId" select="umbraco.library:GetHttpItem('umbMemberLogin')"/> will return both numeric MemberId's as well as Member Login Names like you stated.

    Ex: site.com/profiles/mike.aspx returns mike

    and site.com/profiles/1091.aspx returns 1091

    So now I'm left with making my own XSLT extension to return MemberId's from Member Names.

    My current XSLT looks like this (for testing) and seems to be working great (though it can't validate).

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
       version="1.0" 
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns:msxml="urn:schemas-microsoft-com:xslt"
       xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:MailEngine="urn:MailEngine" 
       exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets MailEngine ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="memId" select="umbraco.library:GetHttpItem('umbMemberLogin')"/>
    <xsl:variable name="xmlMember" select="umbraco.library:GetMember(number($memId))"/>

    <xsl:template match="/">

    <div id="umbProfile">
               <h3>
                   <xsl:value-of select="$xmlMember/@nodeName"/>
               </h3>

               <dl>
                   <xsl:for-each select="$xmlMember/data">
                       <xsl:if test=". != ''">
                           <dh>
                               <xsl:value-of select="@alias"/>:
                           </dh>
                           <dd>
                               <xsl:value-of select="."/>
                           </dd>
                       </xsl:if>
                   </xsl:for-each>
               </dl>
    </div>


    </xsl:template>

    </xsl:stylesheet>

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 26, 2009 @ 10:48
    Morten Bock
    0

    Sometimes XSLT doesn't validate when passing variables to extension methods, because the variables have no values a design time.

    If you want to see the complete XML for the member you get back, write it out like this:

    <xsl:copy-of select="$xmlMember" />

    And then view your macro on a page. It will write out the XML to the source of your page.

     

Please Sign in or register to post replies

Write your reply to:

Draft