|
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
|