Copied to clipboard

Flag this post as spam?

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


  • Ivan 139 posts 302 karma points
    Feb 21, 2012 @ 22:00
    Ivan
    0

    Clear Umbraco cache to read updated Member profile values

    Hi.

    I am using osMember controls to create a member profile section. Otherwise, at the top of this section template, i have an XSLT block where a logged member can read a few lines about his profile like a welcome message with his member_firstname field and another field that shows member_location.

    Everything works perfectly except for one thing. Whenever a member updates his profile information, the top section information rendered via XSLT is not updated.

    I mean, if  i change my profile location from "city_A" to "city_B", and even if it is correctly stored, at the top users area i still reads the welcome message with old location "city_A".

    I tried adding the following lines to my "MemberProfile.ascx.cs" code to get Umbraco Cache cleared without success:

    umbraco.library.UpdateDocumentCache(n.Id);
    HttpRuntime.UnloadAppDomain();
                       
    Member.RemoveMemberFromCache(m.Id);
    Member.ClearMemberFromClient(m.Id);
    Member.AddMemberToCache(m);

    What is strange is that If i save member profile information three times in a row, then i get top XSLT block information updated.

    Any ideas?

     

     

  • Simon steed 374 posts 686 karma points
    Jun 20, 2012 @ 17:25
    Simon steed
    0

    Have you tried the following? Obviously this is creating a user but does invalidate the cache

    //create a member
    Member m =Member.MakeNew("John Smith", mt,new umbraco.BusinessLogic.User(0));

    //set a property value on the member
    m
    .getProperty("address").Value="Lipsum street 223, 9000 Beton";

    //Generate member Xml Cache
    m
    .XmlGenerate(newSystem.Xml.XmlDocument());

    //Save member
    m
    .Save();
  • Ivan 139 posts 302 karma points
    Jul 03, 2012 @ 10:48
    Ivan
    0

    Thanks for your reply Simon.

    Finally I solved it using an XSLT workaround.

  • Simon steed 374 posts 686 karma points
    Jul 03, 2012 @ 10:58
    Simon steed
    0

    Cool no worries - care to add the workaround so we can all benefit?

  • Ivan 139 posts 302 karma points
    Jul 03, 2012 @ 11:08
    Ivan
    0

    Sure. I created a "SessionLibrary.xslt" file to store current location similiar to the one i use for multilanguage 1:1 solutions.

    <!-- Current Member ID -->
    <xsl:variable name="memberID" select="umbraco.library:GetCurrentMember()/@id" />
    <xsl:variable name="currentMember" select="umbraco.library:GetMember($memberID)" />    
        
        <xsl:param name="initzona">
        <xsl:choose>
          <xsl:when test="$currentMember/node/member_location != ''">
            <xsl:value-of select="$currentMember/node/member_location" />
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="number(1081)"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:param>
      
      <xsl:variable name="dzona">

          <xsl:choose>        
            <xsl:when test="umbraco.library:RequestQueryString('zona') != '' ">
              <xsl:value-of select="umbraco.library:RequestQueryString('zona')" />
            </xsl:when>
            <xsl:when test="umbraco.library:Session('zona') != ''">
              <xsl:value-of select="umbraco.library:Session('zona')" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$initzona" />
            </xsl:otherwise>
          </xsl:choose>

      </xsl:variable>
      <xsl:variable name="fzona">
        <xsl:if test="$dzona != '' and $dzona != $initzona ">
          <xsl:value-of select="concat('',$dzona)" />
        </xsl:if>
      </xsl:variable>
      
      <xsl:template name="setzone">
        <xsl:value-of select="umbraco.library:setSession('zona',$dzona) " />
      </xsl:template>

    Then i include this file wherever i need to get selected location.

    <!-- Include Session Library -->
    <xsl:include href="../xslt/SessionLibrary.xslt" />    

    <xsl:template match="/">
    <!-- Set zone variable session -->
    <xsl:call-template name="setzone" /> 
  • Ivan 139 posts 302 karma points
    Jul 03, 2012 @ 11:11
    Ivan
    0

    By the way. Coul you recommend me a cheap hosting service for umbraco? I am currently workin with Arvixe but having a lot of problems lately, specially with databases. I was previously working with DotNetHost without problems but is no longer offering hosting services.

Please Sign in or register to post replies

Write your reply to:

Draft