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

Need to know how to create a second header.phtml
 
eluminous
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2008-11-05
Victoria, Australia
 

I have two unique layout pages created to display different front-end looks on each. What I would like to do is created a second header.phtml file to call a different header configuration than is set out in my standard header.phtml file.

Does the following sound like a feasible way to tackle the goal?:

First, I created a second header file and called it “headerhome.phtml” inside my “frontend/default/dec-decor/template/page/html” folder, then I set up a duplicate block in my page.xml file which mirrors the first header file code and renamed the parent block info as listed in the code below. I have managed to get the new header to be called and displayed in my second template on the frontend, but cant get the nested “block” elements inside second header file to display and I feel that I am missing some important logic to the way that blocks are referenced in the .xml files.

This is the block I have created in page.xml:

<block type="page/html_header" name="headerhome" as="headerhome" template="page/html/headerhome.phtml">
            
    <!-- 
breadcrumbs here -->
    <
block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
            
    <
block type="page/template_links" name="top.links" as="topLinks"/>
                
    <
block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
                
    <
block type="core/text_list" name="top.menu" as="topMenu"/>

</
block>

A. I dont have a grasp on the full breakdown of the code referencing in the type=, name= and template= tags? I’m ok with the “as=” tag. That is how the templates are called in the layout file…

B. Is the “underscore” in the “type=” tag a folder separator?? If so, where does the underscore work / not work?

C. Why do some blocks need a template reference and some don’t? Again, I am not fully sure of the breakdown in logic here…

I have read through lots of pages, videos and posts, and any documentation which attempts to explain the breakdown of this “block” code logic seems very wishy washy… (just my opinion)

Because I have called the “headerhome.phtml” file (that’s the new header file I have created) directly from an explicit location through the “template=” tag, would I be correct in assuming this is why the nested “blocks” in page.xml aren’t being pulled in as well?… yes/no?

I have spent weeks with Magento getting a handle on it’s abstract customisation ability, and I gotta tell you it’s not your average bear!  We’re getting there though smile

Thanks in advance for your input…

 
Magento Community Magento Community
Magento Community
Magento Community
 
eluminous
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2008-11-05
Victoria, Australia
 

Ok. Let me break this down into digestible chunks to see if I can get any response:  wink

A. Is the underscore in “type=” a folder separator?

B.  What exactly is the “name=” referring to?

C. When should one use the “template=” tag and when should one not?

D. Is my example above possible to do without hacking the core code?

TIA

 
Magento Community Magento Community
Magento Community
Magento Community
 
iiNTENSE
Guru
 
Avatar
Total Posts:  432
Joined:  2008-11-06
Lansing, MI
 

Why not just create a new file (example: header1.phtml), and call it out in your column.phtml?

The header.phtml file is just a name of the file, essentially you could put that file in the footer if you wanted to.

 
Magento Community Magento Community
Magento Community
Magento Community
 
eluminous
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2008-11-05
Victoria, Australia
 
iiNTENSE - 25 November 2008 11:59 PM

Why not just create a new file (example: header1.phtml), and call it out in your column.phtml?

Sorry, you’ve lost me.... there is no file column.phtml? Are you referring to (1), (2), (3), column-(right/left).phtml layout files? Or are you referring to creating one?

The header.phtml file is just a name of the file, essentially you could put that file in the footer if you wanted to.

Yes I know this… More specifically, I was asking about the breakdown of code and xml logic in relation to Magento. I tried creating a second version of the header and calling it in my 2columns-right.phtml template file but it would only display the html content and not the getChildHtml calls within the second header file. So, hence my asking about the logic of xml hierarchy in Magento (refer post 1)…

Forgive me if I seem to be over complicating this…

 
Magento Community Magento Community
Magento Community
Magento Community
 
iiNTENSE
Guru
 
Avatar
Total Posts:  432
Joined:  2008-11-06
Lansing, MI
 

I was referring to the 1,2,3 column.phtml files.

Well....you may or may not be over complicating it.  Depending on what you are trying to accomplish, you may not need the getChildhtml call. 

It’s always better to work smarter than harder.  What are you trying to implement requiring you to create a getChild? You may not need it if you just want to callout PHP, HTML or CSS

 
Magento Community Magento Community
Magento Community
Magento Community
 
acaffiero
Jr. Member
 
Total Posts:  6
Joined:  2009-01-13
 

Hi, I am having the EXACT same problem you are having, or did have.  Did you find any solution?  I would really appreciate any info.  acaffiero@gmail.com

Thanks,

Anthony

 
Magento Community Magento Community
Magento Community
Magento Community
 
eluminous
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2008-11-05
Victoria, Australia
 

Hi Anthony,

In this particular instance I did end up keeping the header.phtml file as sparse as possible, then simply working within the templating framework to build out the customised pages. With all other work I had going on at the time I simply couldn’t allocate the resources to get an alternate solution happening.

I know this doesn’t answer your query at all, but since you have posed this question it has prompted me to delve back into it and try to find a possible solution or suitable workaround for future reference. Dont know about timeframe though. Sorry.

Warm Regards
Steve

 
Magento Community Magento Community
Magento Community
Magento Community
 
Yannick Tessier
Jr. Member
 
Total Posts:  2
Joined:  2008-10-03
 

Steve / Anthony,

I have been experiencing the same or a similar nightmare. Consider the following: a partial template (.phtml) file is referenced in a static block, then in turn , that static block is referenced by a cms/page’s custom design layout update (xml). 

In the cms/page’s layout update if I call my static block directly within my <reference> node, the contents are rendered as expected.  When I call the block nested within another <block> node, the dynamic content is rendered as text.

The same is true if I call the phtml block directly in the same manner.

Still scratching my head on this one.  I will most probably resort to building a new template at this point, but I would still like to understand what causes the contents to not render as expected when the block is nested within another block.

Yannick

 
Magento Community Magento Community
Magento Community
Magento Community
 
jotein
Jr. Member
 
Avatar
Total Posts:  5
Joined:  2008-05-18
Madrid, spain
 

I had the same problem figuring out how to reference blocks and i found this which helped me to get thing done.

for instance, to get top.links in a new template instead of this:

$this->getChildHtml(’topLinks’)

use this:

<?=$this->getLayout()->getBlock('top.links')->toHtml()?>

And so on.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top