<![CDATA[Magento Help]]> http://magentist.com/magento_help/ Sun, 05 Feb 2012 14:11:22 +0000 Zend_Feed http://blogs.law.harvard.edu/tech/rss <![CDATA[Move Elements In Magento Templates]]> http://magentist.com/magento_help/move-elements-in-magento-templates/ Magento templates is usually fairly simple. A quick drag-and-drop of a small PHP script within a PHTML file is usually all you need.

But what if the layout you want to achieve would require you to move that PHP script to a different PHTML file? This may be fine on occassion, but you may often find that this will fail to output your content.

As an example, let's say you want to move your topLinks bar (the My Account, My Wishlist, My Cart, etc links) from the header.phtml file to the page layout files (1column.phtml, 2columns-left.phtml, etc). The php code you're looking for in header.phtml will look like this:

<?php echo $this->getChildHtml('topLinks') ?>
This cannot be directly transferred to the layout files because the PHP is requesting ChildHtml, and topLinks is a child of header.phtml, not the layout files. The solution? Reformat the PHP! Instead of using getChildHtml, use getLayout()->getBlock. This format should work in virtually any PHTML file in your Magento templates. The new code for our example would look like this:

<?php echo $this->getLayout()->getBlock('top.links')->toHtml()?>
Notice that the identifier has changed from "topLinks" to "top.links" The new identifier is the block's name, whereas the old identifier used the block's alias. This information was gathered from /app/design/frontend/default/template-name/layout/page.xml on this line:

<block type="page/template_links" name="top.links" as="topLinks"/>
]]>
Fri, 30 Jul 2010 18:50:40 +0000
<![CDATA[Remove Sidebar Blocks With Layout Update XML]]> http://magentist.com/magento_help/remove-sidebar-blocks-with-layout-update-xml/ Magento's sidebar comes with lots of great features like a quick view of your shopping cart and items you've marked to compare.

But what if you don't want to use all of those items on a page? Sure, you could disable features, but what if you only want to hide features on a specific page?

Say, for example, you want to create a homepage using the 2-columns-left layout. Having the sidebar navigation available on your homepage could be a great way to increase accessibility on your site, but the Shopping Cart and other features may not be appropriate for the home page.

The best solution for a scenario like this is to remove unwanted blocks from a specific page using Layout Update XML.

For this example you would set up your categories and your homepage as usual, and then to remove the extra sidebar blocks on the homepage, go to edit your homepage’s CMS page, and under Layout Update XML, create the appropriate remove tags, as in this example:

<reference name="left">
	<remove name="cart_sidebar"></remove>
	<remove name="catalog.compare.sidebar"></remove>
	<remove name="sale.reorder.sidebar"></remove>
</reference>
This method can be used on CMS pages, categories, product pages - just about anywhere on your site!

For more help on this topic, ask a real Magento Expert at http://magentoexpert.com/ and get a quick answer to your Magento question for free!]]>
Tue, 06 Jul 2010 21:12:46 +0000