4

I am trying to get a hero carousel on my homepage that I also want at the bottom of some other pages, like my search results page. The content is the same, but the div it is wrapped in needs different Foundation grid classes for each page.

So, I made a core/template phtml file for each of the locations and I want to call it in to, and they are working. Each of those has a div with the grid classes I need and inside it has <?php echo $this->getChildHtml('heroCarousel') ?> from a third core/template phtml file.

I know I need to identify this last phtml template with as="", and I have done this kind of thing once before, for example, for the search results page using this code:

<catalogsearch_result_index>
     <block type="cms/block" name="full_width" as="full_width">
         <action method="setBlockId"><block_id>full_width_static_block</block_id></action>
     </block>
</catalogsearch_result_index>

How can I do the same for the homepage? I have to identify the .phtml template with as="" before I can call it in with <?php echo $this->getChildHtml('heroCarousel') ?>, right? If that is so, what is the handle for doing this on the homepage?

Thanks.

3
  • I suggest you install mgt-commerce.com/magento-developer-toolbar.html . This is an extension that is very helpfully when learning magento Commented Nov 17, 2014 at 5:52
  • @DannyDevNz Thanks, I installed it. It's only appearing in the admin. Is that right?
    – b_d_m_p
    Commented Nov 17, 2014 at 8:30
  • Figured it out. I put it in the default theme and not my theme.
    – b_d_m_p
    Commented Nov 17, 2014 at 10:57

1 Answer 1

4

try with below

<cms_index_index>    

 <block type="cms/block" name="full_width" as="full_width">
         <action method="setBlockId"><block_id>full_width_static_block</block_id></action>
     </block>

</cms_index_index>

if you wish to call it within in conten part you can use like

 <cms_index_index>    
   <reference name="content">    
     <block type="cms/block" name="full_width" as="full_width">
             <action method="setBlockId"><block_id>full_width_static_block</block_id></action>
         </block>
   </reference> 
    </cms_index_index>

or if you need to make your block as root block then you can use it.

 <cms_index_index>    
   <reference name="root">
     <block type="cms/block" name="full_width" as="full_width">
             <action method="setBlockId"><block_id>full_width_static_block</block_id></action>
         </block>
   </reference> 
    </cms_index_index>

you can change or edit to give any parent reference tag before your block tag

6
  • Thank you. Can you explain the last part of your comment once more? I'm not following completely.
    – b_d_m_p
    Commented Nov 17, 2014 at 5:55
  • @b_d_m_p, see my updates.hope you can now understand more and will help you.
    – liyakat
    Commented Nov 17, 2014 at 6:01
  • Thank you again. I see now. Just out of curiosity, if the html is called in with <?php echo $this->getChildHtml('full_width') ?>, and that is in the phtml file, doesn't that give the location? Why do the xml files require reference location? Wouldn't the system make more sense if the block template was identified with as="", and then could be called in with getChildHtml anywhere, in any phtml file? I'm just trying to wrap my head around that logic. It seems redundant, no?
    – b_d_m_p
    Commented Nov 17, 2014 at 6:08
  • i will be happy. if i could give you correct answer. More or less its design pattern followed by magento. you can refer this magentocommerce.com/design_guide/articles/… to understand more on this. see next page as well.
    – liyakat
    Commented Nov 17, 2014 at 6:12
  • I've read the docs a bunch, but I guess it hasn't clicked for me yet. Thanks a lot. I appreciate all your help.
    – b_d_m_p
    Commented Nov 17, 2014 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.