Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Customizing the top links with username, sentence structure
 
flufftronix
Member
 
Avatar
Total Posts:  45
Joined:  2007-11-09
Philly, PA
 

Hiya

So I’m trying to personalize the Top Links a little; those which read:

* My Account
* My Wishlist
* My Cart
* Checkout
* Log In

I’d like to have multiple possible outputs, depending on the status of the user’s cart and if he/she is logged in. For registered users I’d like to display:

You’re logged in as ________ (full name). View your account, wishlist, cart, _____ (if there are products in the cart display “check out,") or log out.

and then if someone’s not logged in to display

You’re logged in as a guest (no account required for purchase). View your, wishlist, cart, _____ (if there are products in the cart display “check out,") log in, or register.

If any of you know how to do all of this, or even bits and pieces please do tell. Thanks much!

EDIT: I’ve figured out where to change the * My Account link, though the others remain a mystery. I’ve also added in commas, but they appear after the last item as well. More workin on this tomorrow..

 
Magento Community Magento Community
Magento Community
Magento Community
 
flufftronix
Member
 
Avatar
Total Posts:  45
Joined:  2007-11-09
Philly, PA
 

bbbbump
..anyone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
flufftronix
Member
 
Avatar
Total Posts:  45
Joined:  2007-11-09
Philly, PA
 

one more bump. would love to solve this..

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

Something like ]this (update: replaced with screenshot)?

Ignore the ‘home’ and messy presentation, as I quickly made it so that you can see the real example. Try register an account so that you can see the logged in version.

Quite a bit of hacking though

1) In the Admin > System > Configuration > Design > Header, change ‘Welcome text’ to ‘You’re logged in as ‘

2) In the layout > customer.xml, remove the first <!--Default layout, loads most of the pages -->, then in the next two,

<customer_logged_in> and <customer_logged_out>, replace this:

<!--
Load this update on every page when customer is logged in
-->

    <
customer_logged_in>
        <
reference name="top.links">
         <
action method="addLink" translate="label title" module="customer"><label>View your Account,</label><url helper="customer/getAccountUrl"/><title>View your Account,</title><prepare/><urlParams/><position>10</position></action>
         
            <
action method="addLink" translate="label title" module="customer"><label> or Log Out</label><url helper="customer/getLogoutUrl"/><title>or Log Out</title><prepare/><urlParams/><position>100</position></action>
        </
reference>
    </
customer_logged_in>

<!--
Load this update on every page when customer is logged out
-->

    <
customer_logged_out>
        <
reference name="top.links">
      
         <
action method="addLink" translate="label title" module="customer"><label>Guest</label><url helper="customer/getAccountUrl"/><title>Guest</title><prepare/><urlParams/><position>10</position></action>
            <
action method="addLink" translate="label title" module="customer"><label>Log In or Register</label><url helper="customer/getLoginUrl"/><title>Log In or Register</title><prepare/><urlParams/><position>100</position></action>
        </
reference>
        <
remove name="reorder"></remove>
    </
customer_logged_out>

3) In the code > core > Mage, look for
a) Checkout > Block > Links. php, under “public function addCartLink()”, change the 3 ‘My Cart’ wording to ‘Cart’ - add ‘comma’ after the “"(%d items)”
b) Wishlist > Block > Links.php, under “public function addWishlistLink()”, change the 3 “My wishlist” wording to “wishlist” add ‘comma’ after the “"(%d items)”.

I didn’t test it intensively, but quite sure it won’t cause error.

As for the presentation, you can replace the ‘.quick-access li {float:left;}’ to

.quick-access li {display:inline}

In my template, quick-access is placed inside the ‘header.phtml’

<div class="quick-access">
<strong><?php echo $this->htmlEscape($this->getWelcome()) ?></strong>

<?php echo $this->getChildHtml('topLinks') ?>
</div>

It’s possible to remove the <ul><li>...</li></ul> and display span class with p tag like so

<div class="quick-access">
<p><strong><?php echo $this->htmlEscape($this->getWelcome()) ?></strong>

<?php echo $this->getChildHtml('topLinks') ?></p>
</div>

In ‘top.links.phtml’ file, you replace the <ul><li>...</li></ul> to

<span<?php if($_toplink['first']||$_toplink['last']): ?> class="<?php if($_toplink['first']): ?>first <?php endif; ?><?php if($_toplink['last']): ?>last <?php endif; ?>"<?php endif; ?> <?php echo $_toplink['liParams'] ?>> <?php echo $_toplink['beforeText'] ?><a <?php echo $_toplink['aParams'] ?>><?php echo $_toplink['innerText'] ?></a><?php echo $_toplink['afterText'] ?></span>

So if you go with p tag and span, ignore/remove the ‘quick-access li’, change it to

.quick-access p span { } /* don’t think ‘display:inline’ is needed as span is an inline element */
.quick-access p span a {color:#369 }/* for example */

Image Attachments
toplinks.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
flufftronix
Member
 
Avatar
Total Posts:  45
Joined:  2007-11-09
Philly, PA
 

That seems about right! Though on your example page it says “You’re logged in as” upon first visit

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

If you look carefully, on second tab it reads ‘guest’. I did mention to ignore the ‘home’ smile That is for my template and I wasn’t bother to remove it

Anyway, I just wanted to add that my suggestion on using <span> element and remove the UL tag won’t work well because in the

Page > Block > Html >Toplink.php, the toplinks are generated from ‘’liParams’’. I think it’s possible to change all ‘’liParams’ to ‘’spanParams’

 
Magento Community Magento Community
Magento Community
Magento Community
 
flufftronix
Member
 
Avatar
Total Posts:  45
Joined:  2007-11-09
Philly, PA
 

Ah, gotcha. How about inserting text that’s not part of the links? ie for “or log out” just “log out” would be the link. Just can’t figure out how to insert plain text into the customer.xml output..

 
Magento Community Magento Community
Magento Community
Magento Community
 
nadshez
Member
 
Avatar
Total Posts:  48
Joined:  2008-04-16
 

Search for all instances of

name="top.links”

in XML & suffle or delete as necessary. However, adding your links can be also straight forward .. by using the usually underestimated CMS static blocks.

So to add your own links, create a CMS block & give it identifier ‘myTopLinks’ .. block name can be anything. Following code adds the contact us link

<ul class="links">
<
li><a href="{{store url="contacts/"}}">Contact</a></li>
</
ul>

Next open up template\page\html\header.phtml and your code would change from

<class="welcome-msg"><?php echo $this->getWelcome()?></p>
            
<?php echo $this->getChildHtml('topLinks'?>

to this

<class="welcome-msg"><?php echo $this->getWelcome()?></p>
            
<?php echo $this->getChildHtml('topLinks'?>
            <?php 
echo $this->getLayout()->createBlock('cms/block')->setBlockId('myTopLinks')->toHtml() ?>

Hope this helps.
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top