Skip to content

Instantly share code, notes, and snippets.

@rossmc
Forked from Maksold/local.xml
Last active August 29, 2015 14:05
Show Gist options
  • Save rossmc/de4e93f65e69c3f14c22 to your computer and use it in GitHub Desktop.
Save rossmc/de4e93f65e69c3f14c22 to your computer and use it in GitHub Desktop.
Useful Magento Layout xml
<?xml version="1.0"?>
<layout>
<default>
<!--Root/Default Layouts-->
<reference name="root">
<!--Appending Block-->
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
</reference>
<!--CSS and JS Files-->
<reference name="head">
<!--Add CSS and JS, skin Folder-->
<action method="addItem"><type>skin_css</type><name>css/styles.css</name></action>
<action method="addItem"><type>skin_js</type><name>js/functions.js</name></action>
<!--Remove CSS and JS, skin Folder-->
<action method="removeItem"><type>skin_js</type><name>scripts/functions.js</name></action>
<action method="removeItem"><type>skin_css</type><name>css/styles.css</name></action>
<!--Remove JS, js Folder-->
<action method="removeItem"><type>js</type><name>scripts/functions.js</name></action>
</reference>
<!--Add Google fonts to head-->
<reference name="head">
<block type="core/text" name="google.font.oswald">
<action method="setText">
<text>
<![CDATA[
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700' rel='stylesheet' type='text/css'>
]]>
</text>
</action>
</block>
</reference>
<!-- Editing Magento top links -->
<!-- http://www.classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way -->
<reference name="root">
<reference name="top.links">
<action method="addLink" translate="label title">
<label>About Us</label>
<url>about</url> <!-- can use full url also -->
<title>About Us</title>
<prepare>true</prepare> <!-- set true if adding base url param -->
<urlParams helper="core/url/getHomeUrl"/> <!-- base url - thanks @Russ! -->
<position>1</position>
<liParams/>
<aParams>class="top-link-about-us"</aParams>
<!-- there are a few param you can send to do different things in <urlParams>
dig into app/code/core/Mage/Core/Model/Url.php, around line 803 -->
</action>
<!-- To remove links -->
<remove name="wishlist_link"/>
<remove name="checkout_cart_link"/>
<action method="removeLinkByUrl"><url helper="customer/getRegisterUrl"/></action>
<remove name="storelocator"/>
<!-- To re-add 'My Cart' or 'Checkout' after removing both -->
<block type="checkout/links" name="checkout_cart_link_custom">
<action method="addCartLink"></action>
<action method="addCheckoutLink"></action>
</block>
<!-- login/logout links can also be removed from within the customer_logged_out / in handles
<action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
-->
</reference>
</reference>
<!--Header-->
<reference name="header">
<!--Append CMS Block-->
<block type="cms/block" name="header.cms.block" as="headerCmsBlock">
<action method="setBlockId"><block_id>header_cms_block</block_id></action>
</block>
</reference>
<!--Change Block's Template if some Configuration is Set-->
<reference name="catalog.topnav">
<action method="setTemplate" ifconfig="pronav/pronavconfig/pronav_status">
<template>pronav/navigation_top.phtml</template>
</action>
</reference>
<!-- Add a CMS block to the left structural block -->
<reference name="left">
<block type="cms/block" name="left-menu">
<action method="setBlockId"><block_id>left-menu</block_id></action>
</block>
</reference>
<!--Magento's Default Sidebar Blocks-->
<remove name="cart_sidebar"/> <!--Cart Sidebar-->
<remove name="catalog.product.related"/> <!--Related products sidebar-->
<remove name="wishlist_sidebar"/> <!--Wishlist Sidebar-->
<remove name="catalog.compare.sidebar"/> <!--Compare Items Sidebar-->
<remove name="right.permanent.callout"/> <!--Right Callout Sample Data-->
<remove name="left.permanent.callout"/> <!--Left Callout Sample Data-->
<remove name="right.reports.product.viewed"/> <!--Viewed Products-->
<remove name="right.reports.product.compared"/> <!--Compared Products-->
<remove name="catalog.leftnav"/> <!--Layered Navigation-->
<remove name="left.newsletter"/> <!--Sidebar Newsletter-->
<remove name="right.poll"/> <!--Poll-->
<remove name="tags_popular"/> <!--Popular Tags-->
<remove name="paypal.partner.right.logo"/> <!--Paypal logo Sample Data-->
<remove name="catalogsearch.leftnav"/> <!--Layered navigation on search result page-->
<remove name="sale.reorder.sidebar"/> <!--Reorder Sidebar When User Logged, in Dashboard-->
<remove name="customer_account_navigation"/> <!--Customer Navigation-->
</default>
<!--Add Tabs & Change Titles for tabs on Product View page -->
<!--You also need to create a template in the template/catalog/product/view/ directory -->
<!--see https://gist.github.com/rossmc/d3650bbc178ba818761b -->
<!--See: https://gist.github.com/rossmc/8f06aed09f1599160f75 -->
<catalog_product_view translate="label">
<reference name="product.info">
<block type="catalog/product_view_description" before="product.description" name="product.programs" as="programs" template="catalog/product/view/programs.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Programs</value></action>
</block>
<block type="catalog/product_view_description" after="product.description" name="product.ingredients" as="ingredients" template="catalog/product/view/ingredients.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Ingredients</value></action>
</block>
<block type="catalog/product_view_description" after="product.ingredients" name="product.nutritional.info" as="nutritional.info" template="catalog/product/view/nutritional-info.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Nutritional Info</value></action>
</block>
<block type="catalog/product_view_description" after="product.nutritional.info" name="product.usage" as="usage" template="catalog/product/view/usage.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Usage</value></action>
</block>
<reference name="product.description">
<action method="setTitle" translate="value"><value>Benefits</value></action>
</reference>
</reference>
</catalog_product_view>
<!--Home Page-->
<cms_index_index>
</cms_index_index>
<!--All Cms Pages-->
<cms_page>
</cms_page>
<!--Category View-->
<catalog_category_view>
<!--Set Page Template-->
<reference name="root">
<action method="setTemplate">
<template>page/3columns.phtml</template>
</action>
</reference>
</catalog_category_view>
<!--Category View With Layered Navigation-->
<catalog_category_layered>
</catalog_category_layered>
<!--Onepage Checkout Index Page-->
<checkout_onepage_index>
</checkout_onepage_index>
<!--Onepage Checkout Success Page-->
<checkout_onepage_success>
</checkout_onepage_success>
<!--Customer Accound Pages-->
<customer_account>
<!--Adds Body Class For All Dashboard Pages - MUST when Dashboard is present-->
<reference name="root">
<action method="addBodyClass"><className>customer-account-page</className></action>
</reference>
</customer_account>
<!--Customer Logged In-->
<customer_logged_in>
</customer_logged_in>
<!--Customer Logged Out-->
<customer_logged_out>
</customer_logged_out>
<!--Product View-->
<catalog_product_view>
<!--Product Information Block-->
<reference name="product.info">
<!--Recently Viewed Products-->
<block type="reports/product_viewed" name="product.viewed" template="reports/recently-viewed.phtml" />
</reference>
</catalog_product_view>
<!--Catalogsearch Result Page-->
<catalogsearch_result_index>
</catalogsearch_result_index>
<!--Advanced Search Result Page-->
<catalogsearch_advanced_result>
</catalogsearch_advanced_result>
<!--Advanced Search Page-->
<catalogsearch_advanced_index>
</catalogsearch_advanced_index>
<!--Cart-->
<checkout_cart_index>
</checkout_cart_index>
<!--Contacts Page-->
<contacts_index_index>
</contacts_index_index>
<customer_logged_out>
<!-- Removes 'Log In' link - Default position: 60 -->
<reference name="top.links">
<action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
</reference>
</customer_logged_out>
<customer_logged_in>
<!-- Removes 'Log Out' link - Default position: 60 -->
<reference name="top.links">
<action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
</reference>
</customer_logged_in>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment