can't move content block to header Magento - magento

I am new magento. I try to play around structure block and content block. when I try to move "My Cart" block from right side to header section. It doesn't work. but once I move another block it works. ex:
<reference name="header">
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.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>
this's work (it show on top page) but when I change reference to "head", this block just disappear. Please guild me.
here's the screenshot that I want.
http://awesomescreenshot.com/0002ivnb10

You have to render the block manually by:
<?php echo $this->getChildHtml('extra_actions'); ?>
in cart phtml template file
Header, head & cart blocks are not core/text_list blocks means they will not render their children automatically

Related

how to add custom page layout pages magento

I have custom layout page
I have added the following code to app/code/core/Mega/page/etc/config.xml
<shop_overview module="page" translate="label">
<label>Shop OverView Page</label>
<template>page/shop_overview.phtml</template>
<layout_handle>shop_overview</layout_handle>
</shop_overview>
This show the "Shop Over View Page" on admin panel in page layout drop-down
I want to remove product list from category for this page layout only.
I tried the following but it is not working.
<shop_overview translate="label">
<label>All One-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate">
<template>page/shop_overview.phtml</template>
</action>
<action method="setIsHandle"><applied>1</applied></action>
</reference>
<reference name="category.products">
<remove name="product_list" />
</reference>
</shop_overview>
Instead of this you can assign static block to this category by changing display mode to Static Block Only.
And then creating and selecting that block for that category.
Reference Link: http://leveluptuts.com/tutorials/magento-community-tutorials/19-how-add-static-block-category-page

magento change block not working properly

I am using magento 1.7
on my product page I have added related product on right sidebar.
there are other block also displayed on sidebar these are
-related product
-recently viewed product
-mycart
-paypal logo
Now I want related product to get displayed after mycart and paypal logo, right now it is displayed on top of right bar
I have used before and after but that is not working.
These is my code
paypal.xml
<reference name="right">
<block type="paypal/logo" name="paypal.partner.right.logo" after="cart_sidebar" template="paypal/partner/logo.phtml"/>
</reference>
catalog.xml
<reference name="right">
<block type="catalog/product_list_related" name="catalog.product.related" after="paypal.partner.right.logo" template="catalog/product/list/related.phtml"/>
</reference>
checkout.xml
<reference name="right">
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.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>
how can I put mycart and paypal logo on top of right bar.
First you need to create or update your local.xml file IF you do not have a local.xml file you can create one in
app->frontend->[Package Name]->[Theme Name]->layout->local.xml
Once this is created you can copy exactly what I have in this post into that file for a start of how to use one.
DO ALL UPDATES THROUGH A LOCAL.XML file not through catalog.xml or checkout.xml !! This will make upgrades significantly easier later down the road. Additionally, you will be able to quickly see all changes you have made to your site in one file. This way I can see what you are actually updating.
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="right">
<!-- <action method="unsetChild"><alias>catalog.product.related</alias></action> -->
<block type="catalog/product_list_related" name="catalog.product.related" after="-" template="catalog/product/list/related.phtml"/>
</reference>
</default>
</layout>
If you end up with two try uncommenting my action method.. I can't remember if you have to declare it in separate reference or within there because I didn't test this but give it a try

How to add different static block to every category

I want to add different static block to every category at some specific places on the page.
how would i do that.????
Reference http://www.partybounty.com
here the blocks in footer and banner are different for every category.
Or you can use Layout Update XML (under custom design tab) on each category which can be controlled from the admin a bit like;
<reference name="content">
<remove name="breadcrumbs" />
<reference name="category.products">
<action method="setPageTitleDisabled"><disabled>1</disabled></action>
</reference>
<block type="page/html_wrapper" name="category.home.left">
<action method="setElementTagName"><value>div</value></action>
<action method="setElementClass"><value>col-left sidebar col3</value></action>
<block type="manufacturers/navigation_left" name="category.home.leftnav" template="manufacturers/navigation/left.phtml"/>
</block>
<remove name="category.description" />
<block type="page/html_wrapper" name="category.home.right" after="category.home.left">
<action method="setElementTagName"><value>div</value></action>
<action method="setElementClass"><value>category-home</value></action>
<block type="core/template" name="category.home.description" template="catalog/category/description.phtml" />
</block>
<block type="catalog/navigation" name="category.home.categories" template="catalog/navigation/categories.phtml" after="category.description">
<action method="setIsMini"><value>1</value></action>
</block>
<block type="homepage/homepagebanner" name="category.home.banner" after="category.home.categories">
<action method="setIsCategory"><value>1</value></action>
</block>
<block type="bestsellers/slider" name="category.home.bestsellers" after="category.home.banner" />
<block type="bundlekits/slider" name="category.home.bundlekits" after="category.home.banner" />
<block type="featuredproducts/listing" name="category.home.featured" after="category.home.bestsellers" />
</reference>
This gives you flexibility for different positioning and including different blocks on a per category basis, downside is it's a little time consuming to setup.
Did you try
Go to Admin Catalog - Manage categories
choose your category
go to Display Mode & choose either static block only or static block & products
go to CMS block & choose the block you have created
See How do I create and edit Static Blocks?
If you want to add the static block to the header/footer you may have to
add a field to your category see http://magecracker.wordpress.com/2012/07/19/how-to-add-custom-fieldattribute-in-magento-category/
then
<?php echo Mage::app()->getLayout()
->createBlock('cms/block')
->setBlockId(Mage::registry('current_category')->getData('block id from custom field'))->toHtml(); ?>
You call following in any category page. You can create different static blocks for each categories and call them depending on requirement or selecting from category edit page
<?php $app = Mage::app(); ?>
<?php echo $app->getLayout()
->createBlock('cms/block')
->setBlockId('your_block_id')->toHtml(); ?>

Magento - extending product.info.addtocart to add new "add to cart buttons"

I would like to add a new add to cart button, much like paypal express checkout button.
I managed to plugin to the form via " product.info.extrahint " but the issue is, when you use this in catalog.xml, it puts your button above the "qty" and "addtocart" button's. What I want to do is add it to the end of the "product.info.addtocart" in catalog.xml
(from catalog.xml)
<block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/>
<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/>
<block type="catalog/product_view" name="product.info.extra_buttons" as="extra_buttons" template="mycustomexpresscheckout/pay.phtml" />
Adding that makes the button appear in the right place, but this isn't how the paypal express button is done. for paypal express, the button is added to the "addtocart" block. Infact, if i remove that block, both my original add to cart and paypalexpress checkout buttons are gone.
Here's the original: http://www.bounceapp.com/86522
Here's my one with the alteredcatalog.xml: http://www.bounceapp.com/86523
Can anyone assist, or point me in the right direction?
Magento 1.6 - default template
You can include block product.info.extra_buttons inside product.info.addtocart as
<block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/>
<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml">
<block type="catalog/product_view" name="product.info.extra_buttons" as="extra_buttons" template="mycustomexpresscheckout/pay.phtml" />
</block>
After that you need to call the child block (product.info.extra_buttons) inside addtocart.phtml as $this->getChildHtml('extra_buttons');
In your local.xml, under the <catalog_product_view> node just put this code and it should work:
<reference name="product.info.addtocart">
<block type="catalog/product_view" name="product.info.extra_buttons" as="extra_buttons" template="mycustomexpresscheckout/pay.phtml" />
</reference>
For me it's working without adding getChildHtml('extra_buttons') in addtocart.phtml. Hope will work for you to...

Change Position of Newsletter Sidebox in Magento

Thank you for any help in advance.
I am trying to change the order in which sideboxes appear in magento. Such as the: My Cart, Newsletter, Poll, Recently Viewed Products.
Currently I am trying to make the Newsletter box display last.
In app/design/frontend/default/MY_TEMPLATE/layout/newsletter.xml
I have the following code:
<default>
<!-- Mage_Newsletter -->
<reference name="left">
<block type="newsletter/subscribe" name="newsletter" after="-" template="newsletter/subscribe.phtml" />
</reference>
</default>
Yet even with after="-" as shown in the code, the newsletter is still showing up 1st.
I have flushed all caches, and have re-indexed every time I make a change to no avail.
EDIT:
Changing
<reference name="left">
TO
<reference name="right">
Moves it to the bottom of the list. However, the column is actually on the left. Any ideas why this works?
It's all in the order of left's sortedChildren entries. Try getting rid of the custom newsletter.xml, creating a local.xml file in your custom theme, and adding the following:
<?xml version="1.0"?>
<layout>
<default>
<action method="unsetChild" block="left">
<block>left.newsletter</block>
</action>
<action method="insert" block="left">
<block>left.newsletter</block>
<sib />
<after>1</after>
</action>
</default>
</layout>
What this does is remove the block reference from the list of sorted children blocks and then adds it again at the end. Ref. Mage_Core_Block_Abstract::insert() [link].
I've employed an unused but valid block attribute for the <action /> tag rather than wrap it in <reference />. I believe the effect is the same.
Check the block names(in layout xml files) which is displaying in your left/right sidebar.
You can find something like this
<reference name="right">
<block type="catalog/product_compare_sidebar" after="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
</reference>
The above code will display cart sidebar then compare sidebar. Consider this is your last block in your sidebar. If you want to newsletter after this block you have to specify
<reference name="right">
<block type="newsletter/subscribe" name="newsletter" after="catalog.compare.sidebar" template="newsletter/subscribe.phtml" />
</reference>
You have to specify block names in after/before element tag. Find your left/right sidebars last block name and use that name in your newsletter block.

Resources