claudiu-c
2/9/2017 - 9:42 AM

magento1 layout snippets xml

magento1 layout snippets xml

==== remove title of the page ====
<cms_page translate="label"> 
       <reference name="content">
        <remove name="page_content_heading"/>
    </reference>
  </cms_page>

==== call title of cms pages ====        
<?php
   $prefix = Mage::getStoreConfig('design/head/title_prefix');
   $title = $this->getLayout()->getBlock('head')->getTitle();
   $processedTitle = trim(substr($title, strlen($prefix)));
?>
<h1><?php echo $processedTitle;?></h1>

==== get template in cms page ====
{{block type="newsletter/subscribe" name="newsletter" template="newsletter/subscribe.phtml"}}

==== insert blocks in cms page ====
{{block type="cms/block" block_id="footer_links_company"}}

==== get template via local ====
<block type="core/template" name="page.html.open_graphs" template="page/html/open_graphs.phtml" />
<?php echo $this->getChildHtml('page.html.open_graphs');?>

==== call CMS block via template file ====
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('your_identifier')->toHtml() ?>

==== call CMS page via template file ====
<?php
    $cmsPage = Mage::getModel('cms/page')->load('home','identifier');
    echo $cmsPage->getContent();
?>

==== call CMS block in local.xml ====
<block type="cms/block" name="page.html.checkout_header">
     <action method="setBlockId"><block_id>checkout_header</block_id></action>
</block>

===== add class to body ==== 
<reference name="root">
    <action method="addBodyClass"><classname>homepage</classname></action>
</reference>

===== use javascript in phtml =====
<script type="text/javascript">// <![CDATA[
      jQuery('html').css("height","100%");
// ]]></script>

===== add js and css files =====
<reference name="head">
<action method="AddJs"><script>name</script></action>
<action method="AddItem"><type>js</type><name>name</name></action>
<action method="AddItem"><type>skin_js</type><name>name</name></action>

<action method="AddCss"><stylesheet>name</style></action>
<!-- this one does not work <action method="AddItem"><type>css</type><name>name</name> -->
<action method="AddItem"><type>skin_css</type><name>name</name>
</reference>