|
hi medlington-
Got you-
Ok, if I’m correct in my interpretations, the attached image is what you want to achieve and also a way you need to achieve it. I honestly don’t see a reason why you’d want to separate those parts into two separate templates, but since this is a reply on technicality, I’ll just focus on how to do what you want to do versus ‘why don’t you wanna do this?’
Before I get started, I want to remind you that this can be done in many different ways, but I’d use this method for better organization.
Basically you will use header.phtml only as the container template for the two separate header areas - I called it header_top and header_bottom for good representation.
Your page/html/header.phtml contain the following template tags.
<?php echo $this->getChildHtml('header_top') ?>
<?php echo $this->getChildHtml('header_bottom') ?>
The header_top and header_bottom doesn’t exists yet and the names does not in any way correlate to the name of the template. You will need to go into layout/page.xml and create those ‘blocks’ you just created before it actually holds any content. Think of it as this - you just created two little baskets called ‘header_top’ and ‘header_bottom’ - and now you need to give it functional properties like - what does it interact with? what’s its purpose? You will also need to place some eggs on those baskets too for content - this will all be done in the ‘layouts’, one of which is page.xml
One logic that will help you now is to understand that the ‘header_top’ and the ‘header_bottom’ blocks you’re about to create are located inside a block called ‘header’. That block is assigned via <?php echo $this->getChildHtml('header') ?> in one of the ‘skeleton templates’ which are either 3columns.phtml, 2colmuns-right.phtml, 2 columns-left.phtml...etc depending on which template is being used for your page structure. Just open up page/3columns.phtml and you will see <?php echo $this->getChildHtml('header') ?> somewhere in the template.
So now you’ve created:
header
--- header_top
--- header_bottom
Remember to make note of the hierarchy there, because now we’re moving on to page.xml.
In page.xml, search for= “page/html_header”. You’ll come across a block that looks something like this:
<block type="page/html_header" name="header" as="header" template="page/html/header.phtml">
If you’ve changed template="page/html/header.phtml" to be template="page/html/header2.phtml" from the previous try, just revert it to header.phtml.
Now nest the following two new block into the ‘header’ block:
<block type="page/html_header" name="header_top" as="header_top" template="page/html/header_top.phtml"/> <block type="page/html_header" name="header_bottom" as="header_bottom" template="page/html/header_bottom.phtml"/>
So now it will follow the following hierarchy (I’m abbreviating the above block assignment):
<block name="header">
<block name="header_top"/>
<block name="header_bottom"/>
</block>
Of course all the other stuff that was nested inside <block name="header"> will remain as is- I’d actually even comment out the blocks you won’t be using.
Now you need to make one more change to the XML in order to accommodate the ‘Home | View Cart | Your Account’ links in your header_top. Right now it’s indiscriminately placed inside the ‘header’ block. You will want to change that, so cut the part in page.xml that says ‘<block type="page/template_links" name="top.links" as="topLinks"/>’ and nest it INSIDE the ‘header_top’ block.
So now it’s looking like this (I’m abbreviating the way the block assignment would actually look):
<block name="header">
<block name="header_top">
<block name="top.links"/>
<block>
<block name="header_bottom"/>
</block>
Now you need to tell the block ‘top.links’ to show up in the header_top.phtml
In order to do that, all you need to do is place the following inside your header_top.phtml
<?php echo $this->getChildHtml('topLinks') ?>
All this is done for hierarchy reason. Remember this?:
header
--- header_top
------- top.links
--- header_bottom
That’s it for the header separation part. It may seem like a lot to digest, but keep paying close attention to every move you’re making with the above instruction, and things will start clicking for you soon :D
Image Attachments
Click thumbnail to see full-size image
|