Magento - have custom 'Footer Links' static block on all Checkout pages - magento

I have added some custom header/footer phtml files to my Magento installation, the footer uses an static block called 'Footer Links' - this is a HTML block added via the Magento 'CMS' section.
It is possible to have some logic which 'hides' or disables this block on any checkout page?

One way to do it would be via the local.xml in /app/design/frontend/yourpackagename/yourthemename/layout/local.xml. The handles that you need to add depend on how your checkout process is configured. Here is some example code to get you started:
<checkout_cart_index>
<remove name="footer">
</checkout_cart_index>
<checkout_onepage_index>
<remove name="footer">
</checkout_onepage_index>
This is removing the entire footer block, but you can use it to remove any block name that you have. Alan Storms layoutviewer module is great for figuring out what the layout handles are: http://alanstorm.com/layouts_blocks_and_templates.

Hi i have a custom code to disable the footer links block in checkout page add this code in footer.phtml file
<?php $page_route=Mage::app()->getRequest()->getRouteName(); ?>
<?php if($page_route !='checkout'){ ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('footer_links')->toHtml() ?>
<?php } ?>
And comment or remove this code in cms.xml file
<block type="cms/block" name="cms_footer_links" before="footer_links">
<action method="setBlockId"><block_id>footer_links</block_id></action>
</block>

Related

Magento 1.9: Add custom block to header

I have this in my local.xml.
<reference name="header">
<block type="core/template" name="wc-customheadblock" template="wc-customheadblock.phtml" />
</reference>
Inside wc-customheadblock.phtml i have:
<div style="height:100px; background-color:green">
<h1>This is the wc custom head block</h1>
</div>
But this block is not appearing in the header. I've tried the same for the sidebars (by changing the xml reference name) and it works just fine. Why does this not work for the header?
This site claims its possible to make add blocks to the header using local.xml!
http://www.classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout
Go to your header.phtml file (app/design/frontend/package/theme/page/html/header.phtml) and place one of the following lines:
<?php echo $this->getChildHtml(); ?>
or
<?php echo $this->getChildHtml('wc-customheadblock'); ?>
Most likely header doesn't render child blocks by default because it would cause some template crashes. On the sidebars, extra childs can be easily appended at the end.

Magento: how to add content to <?php echo $this->getChildHtml('outer-right') ?>

I'm still struggling with magento.
I have a 3 column layout but want to place yet another
widget in the outer right of the content with
<?php echo $this->getChildHtml('outer-right') ?> .
How do I create a .phtml file with the stuff to be output
when <?php echo $this->getChildHtml('outer-right') ?>
is invoked?
Thanks.
You just need to add/stuff your blocks via your layout.xml file inside a block called 'outer-right' in the correct layout handle. When your layout handle is active you will be able to fetch its html by getChildHtml('outer-right')
<cms_index_index>
<block type="core/template" name="outer-right" template="xyz.phtml">
<block type="core/template" name="inside-outer-right-1" template="inside.phtml"/>
<block type="core/template" name="inside-outer-right-2" template="inside2.phtml"/>
</block>
</cms_index_index>

Magento Shortcode CMS block not working on product pages

I am attempting to add a CMS block on a Magento product page.
The shortcode which I am using is:
{{block type="cms/block" block_id="myproductblock"}}
The block shows up as text. It does not insert the CMS block. I have made sure that the WYSIWYG editor is disabled.
I assume you want to add it to product.phtml
To do this, you need to edit the layout/catalog.xml
...
<catalog_product_view>
..
...
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<!-- start your code: -->
<block type="cms/block" name="myproductblock" before="-">
<action method="setBlockId"><block_id>myproductblock</block_id></action>
</block>
Then inside your view.phtml you write:
<?php echo $this->getChildHtml("myproductblock") ?>
Where the "myproductblock" is the same as the name you specified inside the layout.xml
After this you have to clear the layout.xml cache and it should work :)
Why your code didn't work:
Those .phtml files all are php-scripts.. the "{{" and "}}" must interpreted by a template engine and is only valid inside emails, CMS pages/blocks and the wysiwyg editors in the backend.

Magento - moving extension from left/right column to main

I try to move an ext: Customers who bought this product also purchased from default left/right column to main column under the product, but I don't know how to do this.
I try to change the line <product_detail_leftposition translate="label"> to <product_page translate="label"> in system.xml file but it doesn't help.
Any suggestions?
Thanks for any help!
You can do this by adding it to the Products view page section inside your layout XML. Add the block inside the content reference block, somewhere at the bottom.
Make sure it's inside the handle as this defines the structure used on the product view page.
app/design/frontend/[namespace]/[themename]/layout/catalog.xml
<catalog_product_view translate="label">
...
<reference name="content">
...
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<!-- Other blocks etc here.. add at the bottom -->
<block type="module/block" name="yourblock" as="yourblock" />
</block>
</reference>
</catalog_product_view>
This should automatically output the block for you if you add it in here, although that depends on the theme you are using.
if it doesn't automatically show, you may need to add a line to your view to display the block:
app/design/frontend/[namespace]/[themename]/template/catalog/product/view.phtml
<?php // use the block name used in the XML config.. ?>
<?php echo $this->getChildHtml('yourblock') ?>

Trying to build an AJAX cart in Magento, configuration options not showing

PROBLEM:
I'm trying to build an AJAX cart in magento, but I can't seem to fetch the chosen configuration option(s) of configurable products. I believe am invoking the the right method ($this->getOptionList()) to get them. It should return an array with options and labels, but it returns nothing!! To be clear, they are showing up in the normal cart.
EXPLANATION:
The short story of how I'm doing it:
I use the Cart Controller of the Mage_Checkout module, but I change the template to something very minimal (using layout updates in the current theme), and a custom module with a router defined in it.
Long story:
I have created a module MyNameSpace_Checkout in which I have defined a router that binds the frontName 'ajaxcart' to the controllers in the Mage_Checkout module.
Now in the local.xml file of my current theme I put the following layout updates under the 'ajaxcart_cart_index' handle:
<ajaxcart_cart_index>
<reference name="root">
<action method="setTemplate">
<template>ajaxcart/cart/index.phtml</template>
</action>
<block type="checkout/cart" name="checkout.cart" template="ajaxcart/cart/show.phtml" as="cart"></block>
</reference>
</ajaxcart_cart_index>
My template ('ajaxcart/cart/show.phtml') is being used, so this worked pretty well. I tested it when I went to http://domain.com/ajaxcart/cart
index.phtml:
<?php echo $this->getChildHtml('cart'); ?>
show.phtml:
<?php foreach($this->getItems() as $_item): ?>
<?php $_renderer = $this->getItemRenderer($_item->getProductType())->setItem($_item); ?>
<?php /* render an item */ ?>
<?php endforeach; ?>
Seeing as $this in this context refers to the Cart Block of the Mage_Checkout module, and digging around in the method getItemHtml() of this class (its superclass actually) I found that the block object per item in the cart is retrieved using the second line in the show.phtml sample above ($_renderer).
Does anyone know why information is missing? The whole reason I'm using the original controller is that it is probably doing some essential stuff, but it's still not working!!
Thanks in advance.
I found the problem myself, the layout updates (local.xml of the current theme) were the problem:
<action method="addItemRender">
<type>configurable</type>
<block>checkout/cart_item_renderer_configurable</block>
<template>checkout/cart/item/default.phtml</template>
</action>
I took another look at checkout.xml of the base/default theme and it sported some addItemRender (layout xml) methods in the cart/checkout block under the checkout_cart_index handle. Specifically for my problem, the above element was missing and that messed up the rendering of a configurable product item in the cart. A special type of block object needs to be loaded that actually has the (PHP) method getOptionList().

Resources