Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Page 1 of 2
combining top.left.links and top.right.links
 
chinesedream
Guru
 
Total Posts:  744
Joined:  2007-08-31
San Francisco, CA
 

In the demo page, ‘my account’, ‘log in’ and ‘my cart’, ‘my wishlist’ and ‘checkout’ are controlled by top.left.links and top.right.links

how can I combine them together so that it show like so:

<ul>
<li>My account</li>
<li>Login</li>
<li>My wishlist</li>
<li>Checkout</li>
</ul>

Also, I want to eliminate the ‘my cart’.  I can take care of CSS position, but I don’t seem able to make it work by removing one of the blocks from main.xml and modify the top.link.phtml

<block type="page/html_toplinks" name="top.left.links" as="topLeftLinks"/>
<block type="page/html_toplinks" name="top.right.links" as="topRightLinks"/>

I tried something like this in main.xml and removed the above two block type:

<block type="page/html_toplinks" name="top.links" as="topLinks"/>

in the header.phtml, I modified to this:
<?=$this->getChildHtml('topLinks')?>

As soon as I uploaded the files to my server, my theme is replaced by the default them.

Help please!

Many thanks !

 
Magento Community Magento Community
Magento Community
Magento Community
 
ohminu
Magento Team
 
Avatar
Total Posts:  171
Joined:  2007-08-07
Portland, OR
 

Hi there, chinesedream!

This is a very good question! ... and a very important bug you found. Here’s the fix, AND the way to arrange layout.

For the bug fix
Open app/code/core/Mage/Page/Block/Html/Toplinks.phtml, and search for a line

if (is_array($this->_toplinks)) {
. It should be in line 84. Change this link to say: 
if (is_array($this->_toplinks) && $this->_toplinks{

Now search for

$this->_toplinks[] $toplinkInfo;
and replace it with:
if (is_numeric($position)) {
            $toplinks 
= array();
            foreach (
$this->_toplinks as $i=>$link{
            
if ($position==$i{
                    $toplinks[] 
$toplinkInfo;
                
}
                $toplinks[] 
$link;
            
}
            $this
->_toplinks $toplinks;
        
else {
            $this
->_toplinks[] $toplinkInfo;
        
}

More replaces- replace this:

function addLink($liParams$aParams$innerText$beforeText=''$afterText='')

To this:

function addLink($liParams$aParams$innerText$position=''$beforeText=''$afterText='')

For the layout changes
You say you consolidated all the “topLink” items to <?=$this->getChildHtml('topLinks')?> in header.phtml. This is a good place to start. If you’ve eliminated the topLeftLinks and topRightLinks from the header.phtml, first, you need to make sure the main.xml file reflects this change, that means no more <block> with as="topLeftLinks" or as="topRightLinks" as its attributes - Now it’s all “topLinks”.

Let me walk you through this step by step:
In header.phtml, change this:

<div class="account-access">
               <
strong><?=$this->getWelcome()?></strong<?=$this->getChildHtml('topLeftLinks')?>
            
</div>
            <
div class="shop-access">
                
<?=$this->getChildHtml('topRightLinks')?>
            
</div>

To this:

<div class="account-access">
               <
strong><?=$this->getWelcome()?></strong<?=$this->getChildHtml('topLinks')?>
            
</div>

Now open up main.xml and replace all references of name="top.left.links" and name="top.right.links" to name="top.links". And also change all references of as="topLeftLinks" and as="topRightLinks" to as="topLinks". Now remove the duplicate <block type="page/html_toplinks" name="top.links" as="topLinks"/> in(or somewhere around) line 102.

Now let’s start organizing a few things.

Look for any reference to <reference name="top.links">. You will see all the link blocks nested inside this references.
You say you don’t want the My Cart link - just remove this code:

<block type="checkout/links" name="checkout_cart_link">
                <
action method="addCartLink"></action>
            </
block>

Now locate:

<action method="addLink"><li/><a>href="{{baseUrl}}customer/account/logout/"</a><label>Log Out</label></action>

And change to:

<action method="addLink"><li/><a>href="{{baseUrl}}customer/account/logout/"</a><label>Log Out</label><position>1</position></action>

Now locate:

<action method="addLink"><li/><a>href="{{baseUrl}}customer/account/"</a><label>Log In</label></action>

And change to:

<action method="addLink"><li/><a>href="{{baseUrl}}customer/account/"</a><label>Log in</label><position>1</position></action>

<postion> tag inside the Log In and Log out action basically sets the position of these particular links. <position>1</position> places it in the 2nd place after <position>0</position>. Of course right now <position>0</position> doesn’t exist, because the XML loads everything in the order elements are introduced, and the Log In and Log out breaks this flow by forcing it’s position using <position> tag.

Hope this helps you smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
chinesedream
Guru
 
Total Posts:  744
Joined:  2007-08-31
San Francisco, CA
 

Hi ohminu, thank you so much again!!!!  I am glad I spotted a bug.

Question, will the Toplinks.phtml be updated in the next release or this bug only affect the layout I wanted to achieve?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ohminu
Magento Team
 
Avatar
Total Posts:  171
Joined:  2007-08-07
Portland, OR
 

hey-

The bug fix will be available for everyone in the next release.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Grayson
Member
 
Avatar
Total Posts:  58
Joined:  2007-11-20
Netherlands
 

Hi Minu, thanks for the well-written Design Guide. Unfortunately I’m having problems with Exercise #2, combining the top links into one line on the latest Magento release (0.7.14800). I’ve followed the instructions exactly as they appear in the design guide, but now all I’ve got is the “Default welcome msg!” with no links at all.

My page/html/header.phtml (relevant section, nothing else is changed):

<div class="quick-access">
            <
div class="account-access">
               <
strong><?=$this->getWelcome()?></strong><?=$this->getChildHtml('topLinks')?>
            
</div>
<!--            <
div class="shop-access">
//                <?=$this->getChildHtml('topRightLinks')?>
            
</div>
-->        
</
div>

And my layout/page.xml (relevant section, nothing else is changed):

<block type="page/html_header" name="header" as="header">
                <
block type="page/html_toplinks" name="top.links" as="topLinks"/>

                <
block type="core/text_list" name="top.menu" as="topMenu"/>
</
block>

Thanks in advance for your help, I’m new to XML so I’m probably overlooking something terribly obvious smile.

Edited to add: I did search for and replace all instances of topLeftLinks, topRightLinks, top.left.links and top.right.links (these occurred in layout/checkout.xml, layout/wishlist.xml, and layout/customer.html). Are there other files I missed?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ohminu
Magento Team
 
Avatar
Total Posts:  171
Joined:  2007-08-07
Portland, OR
 

Hello Grayson--

Yes- the design guide will soon be changed to reflect the latest release. But in the mean time, what you have is all correct. I replicated what you did, and I’m seeing the changes as it should be.Perhaps you missed something somewhere? The way I do it is open all the layout xml files and do search & replace for all open files.

Please post the area in the checkout.xml, customer.xml and wishlist.xml that you’ve changed.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Grayson
Member
 
Avatar
Total Posts:  58
Joined:  2007-11-20
Netherlands
 

Hi Minu, thanks for your response. Here are the other changes I made:

customer.xml (changes on lines 45, 55 and 65):

42     <default>
43 
44          
<!-- Mage_Customer -->
45         <reference name="top.links">
46             <action method="addLink" translate="label"><li/><a>href="{{baseUrl}}customer/account/"</a><label>My Account</label></action>
47         </reference>
48     </default>
49 
50 
<!--
51 Load this update on every page when customer is logged in
52 
-->
53
54     
<customer_logged_in>
55        <reference name="top.links">
56             <action method="addLink"><li/><a>href="{{baseUrl}}customer/account/logout/"</a><label>Log Out</label></action>
57         </reference>
58     </customer_logged_in>
59 
60 
<!--
61 Load this update on every page when customer is logged out
62 
-->
63 
64     
<customer_logged_out>
65         <reference name="top.links">
66             <action method="addLink"><li/><a>href="{{baseUrl}}customer/account/"</a><label>Log In</label></action>
67         </reference>
68     </customer_logged_out>
checkout.xml (change on line 32):
31 <!-- Mage_Checkout -->
32        <reference name="top.links">
33             <block type="checkout/links" name="checkout_cart_link">
34                 <action method="addCartLink"></action>
35             </block>
wishlist.xml (change on line 31):
31         <reference name="top.links">
32             <block type="wishlist/links" name="wishlist_link">
33                 <action method="addWishlistLink"></action>
34             </block>
35         </reference>
I did what you suggested, open all the .xml files in layout/ and do a search & replace. I didn’t find any other instances of the left and right links. I did a search of the entire magento/ tree (using Agent Ransack, not Windows search which often misses things) and found one more place that needed changing, in template/catalog/navigation/top.phtml:
41     <?=$this->getChildHtml('topLinks')?>
Still no joy :(.

I don’t think it should be the source of the problem, but I am using a custom interface, in which I’ve changed a few images and a little CSS (background colors only) so far. So all my xml and template files are located in app/design/frontend/my_interface/default. I created my interface by duplicating the default interface in its entirety, so I shouldn’t be missing any files. In the admin I assigned the new interface as the package and left the other fields blank (since I’m using the default theme in that interface). My Magento installation is running on a Linux server, Apache 2.2.3, PHP 5.2.0-8+etch9.

I’m going to go back and try the default interface, make the changes there, and see if it works. I’ll post results in a few minutes . . .

 
Magento Community Magento Community
Magento Community
Magento Community
 
Grayson
Member
 
Avatar
Total Posts:  58
Joined:  2007-11-20
Netherlands
 

I have the same problem using the default interface . . . I just get the “Default welcome msg!” and no links. But here’s an interesting fact: I reloaded the frontend home page after making each change back to the original version. First I reverted page/html/header.phtml and voila, all my links are back, in the original format (two lines) and working properly. This is with all the xml files and top.phtml still reflecting the merge to a single “top.links”.

While I’m here, I have another quick question for you: where should I look for the core/text_list block type? Based on my limited understanding so far, I’d expect it to be in template/core/text/list.phtml. But my template/core/ doesn’t have a text/ directory. It just has three files, messages.phtml, store.phtml and stores.phtml. Am I missing some directories / files? ETA: Never mind, I figured it out. In case it helps someone else: the block types in the xml files refer to locations in app/code/core/Mage/. so <block type=”page/html_header”> refers to the class found in app/code/core/Mage/Page/Block/Html/Header.php, and <block type=”core/text_list”> refers to the class found in app/code/core/Mage/Core/Block/Text/List.php.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Grayson
Member
 
Avatar
Total Posts:  58
Joined:  2007-11-20
Netherlands
 

And it just gets crazier . . .

If I select a non-default theme from my custom interface (see for details), the links are consolidated as they should be after exercise #2. Mind you, the only thing changed in my non-default theme is one image, under skin/frontend/butterwing_madras/xmas/images/; the theme is otherwise completely empty and falling back on the files in the default theme in my custom interface.

Bizarre. The new theme fixes the link problem in the old theme, but doesn’t work properly for the single image it contains (the fallback version of the image in the default theme gets used instead).

It’s almost like Magento is falling back to a lower theme in the hierarchy for some files but not others. It’s definitely using the CSS and images from the custom interface, default theme when I have that assigned in the Admin. But it seems like it’s using my custom interface, default theme for the header.phtml file, but default/default for the xml files (which would explain why changing just header.phtml back to the orignal left and right links restored the original functionality even though the custom xml files were modified to one set of links). Then when I set custom interface, non-default theme, it falls back to the files in the custom interface, default theme - explaining why the consolidated links suddenly work (header.phtml AND the xml files all coming from custom interface, default theme) and the new image doesn’t.

But why it would sometimes use files from the assigned interface & theme, and sometimes from a lower level in the hierarchy, I don’t know, especially since it isn’t consistent behavior (e.g., uses the images on custom/default level when that’s set in Admin, but uses images on lower level when custom/non-default is set in Admin)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Grayson
Member
 
Avatar
Total Posts:  58
Joined:  2007-11-20
Netherlands
 

Well, this problem is “solved” in the sense that when I turned on my laptop this morning and surfed to my shop, the links worked as they were supposed to in my new interface, default theme. No idea why; maybe it was a cache issue after all. Huh. I’m not too happy about not knowing why it didn’t work right yesterday, but I’m glad it’s doing what it’s supposed to based on the changes I made.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ohminu
Magento Team
 
Avatar
Total Posts:  171
Joined:  2007-08-07
Portland, OR
 

Grayson-

Yes, you will need to make sure to either refresh your cache, or to disable your cache. This will ensure your changes are immediately reflected.
You can control cache by going to the Admin Panel, then navigating to Configure -> Cache Management.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Grayson
Member
 
Avatar
Total Posts:  58
Joined:  2007-11-20
Netherlands
 

Hi, Minu--in fact, I did disable the entire cache yesterday and refreshed everything but didn’t see the change. Maybe I was just braindead after so many hours staring at the xml files and didn’t notice smile.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Spek
Member
 
Total Posts:  62
Joined:  2007-11-28
 

After disabling the cache and making changes to page.xml (in a new interface directory infinite/default), I get this error:

Fatal errorCall to a member function addLink() on a non-object in /var/www/magento/app/code/core/Mage/Checkout/Block/Links.php on line 42

These are the changes I made:

changed header.phtml from this:

<div class="account-access">
               <
strong><?=$this->getWelcome()?></strong><?=$this->getChildHtml('topLeftLinks')?>
            
</div>
            <
div class="shop-access">
                
<?=$this->getChildHtml('topRightLinks')?>
            
</div>
        </
div>

to this:

<div class="account-access">
               <
strong><?=$this->getWelcome()?></strong>
            </
div>
            <
div class="shop-access">
                
<?=$this->getChildHtml('topLinks')?>
            
</div>
        </
div>

and page.xml from this:

<block type="page/html_header" name="header" as="header">
                <
block type="page/html_toplinks" name="top.left.links" as="topLeftLinks"/>
                <
block type="page/html_toplinks" name="top.right.links" as="topRightLinks"/>

to this:

<block type="page/html_header" name="header" as="header">
                <
block type="page/html_toplinks" name="top.links" as="topLinks"/>

This is line 42 in Links.php

$this->getParentBlock()->addLink(null'class="top-link-cart" href="'.Mage::getUrl('checkout/cart').'"'$text);

I can’t see a connection between the two to be honest.. what am I missing?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Raymond Brigleb
Member
 
Avatar
Total Posts:  32
Joined:  2007-09-05
 

Frankly, I’m curious where those UL links in the upper right actually live. How do I change their wording, or add my own? I realize there’s info around here on how to merge them into one line (which I never was able to do, but that’s another story...), but I want to have my own navigation items in there as well, and change the order of (or remove) some of the existing ones.

EDIT: Using Grayson’s extensive list above of places to change, I was able to get the links into one list, and started to discover places where the links could be more properly changed. So it’s getting better all the time!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Electric-dsctc
Member
 
Avatar
Total Posts:  35
Joined:  2008-01-21
 

Well… I didn’t get a thing about this......
I try to extrapolate the solution from version 0.6.xx ro 0.7.xxx but get only trouble and broken functions and such..
I get the same error than Ben…

 
Magento Community Magento Community
Magento Community
Magento Community