Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 7 of 7

Thread: Is it possible to have "Welcome [first name]" in the header?

  1. #1
    dov is offline Junior Member
    Join Date
    May 2013
    Posts
    17

    Question Is it possible to have "Welcome [first name]" in the header?

    Once a user has logged in, is it possible to replace the "register/sign up" link with “Welcome [Customer first name]” – and on clicking their name it takes the user to their account page?

    At the moment I have the following in place.


    Code:
                        <div>
                            <a href='<asp:Literal ID="Literal1" runat="server" Text="<%$ Tokens:SignInOut_Link %>" />'
                                class="login">
                                <asp:Literal ID="ltrSignInOutText" runat="server" Text='<%$ Tokens:SignInOut_Text %>' />
                            </a>
                        </div>
                        <div style="float: right">
                            <a href="createaccount.aspx?checkout=False" class="register">
                                Register </a>
                        </div>
    In that register div, if the user is logged in, I would like it to say "Welcome [first name of logged in user]" and clicking their name takes them to their account (account.aspx). If they are not logged in it stays as the above, "Register" with the link to createaccount.aspx?checkout=False.

    How can I go about it?

    Thank you.

  2. #2
    Skriver is offline Senior Member
    Join Date
    Apr 2012
    Posts
    188

    Default

    Could try something like this

    <xsl:when test="/root/System/CustomerFirstName=''">
    <a href="/signin.aspx">Login</a>
    </xsl:when>
    <xsltherwise>
    Welcome, <xsl:value-of select="/root/System/CustomerFirstName" disable-output-escaping="yes" /> |
    <a href="/signout.aspx">Log out</a> | <a href="/account.aspx">My Account</a>
    </xsltherwise>
    </xsl:choose>

    This is from an xml package that is then referenced in the master templates.

  3. #3
    dov is offline Junior Member
    Join Date
    May 2013
    Posts
    17

    Default

    Thanks Skriver.

    I've tried the following, however, both the "register" and "welcome, " (with no name) appear when logged in.

    Code:
                        <div>
                                <xsl:when test="/root/System/CustomerFirstName!=''">
                                Welcome, <a href='/account.aspx'><xsl:value-of select="/root/System/CustomerFirstName" disable-output-escaping="yes" /></a>
                                </xsl:when>
                                <xsl:otherwise>
                                <a href='createaccount.aspx?checkout=False' class='register'>
                                Register </a>
                                </xsl:otherwise>
                                </xsl:choose>
                        </div>
    Last edited by dov; 05-23-2013 at 05:34 AM.

  4. #4
    Skriver is offline Senior Member
    Join Date
    Apr 2012
    Posts
    188

    Default

    Could be the ! in this line

    <xsl:when test="/root/System/CustomerFirstName!=''">

    try removing that perhaps.

    Our code is this and works ok

    <div class="top_links">
    <a class="wishlist" href="/wishlist.aspx">Wishlist</a> |
    <xsl:choose>
    <xsl:when test="/root/System/CustomerFirstName=''">
    <a href="/signin.aspx">Signin</a>
    </xsl:when>
    <xsltherwise>
    Welcome, <xsl:value-of select="/root/System/CustomerFirstName" disable-output-escaping="yes" /> |
    <a href="/signout.aspx">Log out</a> | <a href="/account.aspx">My Account</a>
    </xsltherwise>
    </xsl:choose>
    </div>
    <div class="cart cartsummary"><a href="/shoppingcart.aspx">Your Cart</a></div>
    </div>

  5. #5
    dov is offline Junior Member
    Join Date
    May 2013
    Posts
    17

    Default

    Thanks again, Skriver. This time with pasting your code it displays: Wishlist | Signin Welcome, | Log out | My Account Your Cart

    Could it be that I have to enable an XML package or something else? It doesn't seem to be picking up the fact that the user is logged in, nor the name of the customer..

  6. #6
    dov is offline Junior Member
    Join Date
    May 2013
    Posts
    17

    Default

    Ok just worked it out by adding a custom XML package. Was easier than I thought! Thanks
    Last edited by dov; 05-23-2013 at 07:08 PM.

  7. #7
    Skriver is offline Senior Member
    Join Date
    Apr 2012
    Posts
    188

    Default

    No problem. Happy you sorted it out.