Magento getChildHtml block not rendering - magento

I'm attempting to rearrange some elements on a webpage and my code won't render it its new position.
The top of the page is handled in view.phtml and the bottom in list.phtml. I'm wanting to move form.phtml from view to list.
The xml looks like this:
<block type="review/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml">
<action method="disableGallery"/>
</block>
<block type="review/form" name="product.review.form" as="review_form" template="review/form.phtml"/>
the view.phtml contains this call:
<?php echo $this->getChildHtml('review_form') ?>
However, no dice. I'm very new to Magento, so any help would be great. I've looked into the following questions and more with no results:
Nested block within a reference not rendering when using ->getChildHtml()
Magento $this->getChildHtml('media') return blank
Call magento template via $this->getChildHtml()
Thanks!

As per as your description,review child block is call in under view then...
it should be
<block type="review/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml">
<action method="disableGallery"/>
</block>
<block type="review/form" name="product.review.form" as="review_form">
<block type="page/html_wrapper" name="product.review.form.fields.before" as="form_fields_before" translate="label">
<label>Review Form Fields Before</label>
<action method="setMayBeInvisible"><value>1</value></action>
</block>
</block>
.........

Related

How to call mini cart in footer in magento?

I want to call mini cart in footer.
i have to use below code in xml file
<reference name="footer">
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/topcart.phtml" before="-">
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
<label>Shopping Cart Sidebar Extra Actions</label>
</block>
</block>
</reference>
or <?php echo $this->getChildHtml('top_cart') ?> in footer.phtml.
but its not working for me. please give me any idea for do it.
you name of block is footer_cart so
change
<?php echo $this->getChildHtml('top_cart') ?>
to
<?php echo $this->getChildHtml('footer_cart') ?>
other problem is you are calling the wrong file
change
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/topcart.phtml" before="-">
to
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/sidebar.phtml" before="-">

toolbar,phtml file need to show in another page(splash page list)

I want to show my toolbar.phtml file in other page like splash-page. I just copy <?php echo $this->getToolbarHtml(); ?> from list.phtml file and put it into my splash-page view.phtml file.. also I have checked that the attripute-splash.xml file. there toolbar.phtml file is already placed. like :
<block type="attributeSplash/page_view_product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
but it's not showing into splashpage..
Kindly help..

How can i display header only homepage in Magento?

I want to display header only homepage.
How can i disable header other page?
Hi If your website having one column layout then open the 1column.phtml file and
replace this line
<?php echo $this->getChildHtml('header') ?>
with this,
<?php $page= Mage::getSingleton('cms/page')->getIdentifier();?>
<?php if($page=='home'){ ?>
<?php echo $this->getChildHtml('header') ?>
<?php } ?>
If you want remove this header using xml then follow below steps
step1:create local.xml under app/design/frontend/yourpackage/yourtemplate/layout
code of local.xml is
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="root">
<remove name="headerone"/>
</reference>
</default>
<cms_index_index >
<reference name="root">
<block type="page/html_header" name="header" as="header">
<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" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>
</block>
<block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">
<label>Page Header</label>
<action method="setElementClass"><value>top-container</value></action>
</block>
</block>
</reference>
</cms_index_index>
</layout>
Step2:goto page.xml under app/design/frontend/yourpackage/yourtemplate/layout
Find <block type="page/html_header" name="header" as="header">
change it to
<block type="page/html_header" name="headerone" as="headerone">
You could do this quite easily without any code changes by adding a <remove /> line for the header block in your local.xml and then in the home page layout, adding the header block to the home page in CMS under page layout in the design tab.
Layout is quite powerful in making such a custom mod.

getChild method in a module doesn't seem to refer to a child(?)

I am using the Meanbee Infinite Scroll module in my project. I have it working for normal category product listings. But now I'm attempting to have it activate on my custom made module.
However I am stumped over line 68 in Script.php:
66 return (
67 $block !== false &&
68 $block->getChild('toolbar') !== false && // <-- This line
69 $this->_getPagerBlock() !== false &&
70 $this->_getPagerBlock()->getCollection()
71 );
There is no xml element that has attribute name of toolbar. Even in the normal category xml that is working. So what is "toolbar" refering to?
A var_dump($block->getChild('toolbar')); returns false on my page but not on the normal category product listing page.
My XML is as follows (for clarity):
<block type="mynamespace/mymodule" name="mymodule.view" template="mynamespace/mymodule/view.phtml">
<block type="catalog/product_list" name="product_list" template="toxicfox/giftfinder/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
And the core XML (which works with the Infinite Scroll module) is:
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
As you can see, neither block of XML has any element with an attribute name of "toolbar". The only difference is line 1.
Any help is appreciated.
In the Mage_Catalog_Block_Product_List::_beforeToHtml() method, the toolbar block is retrieved from the layout with the name that was indicated by the setToolbarBlockName action, then set as a child block of the products list with the toolbar alias.
In your case, the problem may be that the $block hasn't been output yet with toHtml(), so that it doesn't know yet about its toolbar child, or something of this kind (hard to say because the extension is commercial).

Magento: Add Block Before Footer

I'm using GrayScale template, and I want to move the recent viewed to a block before the footer.
I need this block with a different color from footer.
So, I removed this block of page.xml:
<block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
And added to footer block of page.xml:
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
<block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
<label>Page Footer</label>
<action method="setElementClass"><value>bottom-container</value></action>
</block>
<block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
<block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
</block>
Perfect!
But, I need this block before footer and not inside...
How can I do this???
Thanks!
Open your Page.xml file and find the following block
<block type="page/html_footer" name="footer" as="footer" template="page/htmlfooter.phtml">
It should be arond line number 100.
Inside the block paste the following code
<block type="reports/product_viewed" name="reports.product.viewed" as="recently_viewed" template="reports/product_viewed.phtml">
<action method="setColumnCount"><columns>4</columns></action>
<action method="setItemLimit"><type>recently_viewed</type><limit>4</limit></action>
</block>
The block should look like this
Now open your footer.phtml file and before the footer, i.e.
<div class="footer-container">
write the following code
<?php echo $this->getChildHtml('recently_viewed') ?>
And change the child block calling like the following
Now any logged in user will be able to view their recently viewed product and yes, it is outside the footer.
You can style it according to your needs, and you can also set the column count from the block itself.
Enjoy.
Try adding this right above the 'footer' section:
<block type="core/text_list" name="review.before.footer" as="review.before.footer" translate="label">
<block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
</block>

Resources