Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Saturday, March 24, 2012

Magento Config.xml

However all the files are merged together during the parsing process.It will help to understand the XML structure. It is the reason that the module name is repeated as an XML element name (represented below as <(modulename)>) several times through every file - this is necessary to segregate configuration for each module. Without these elements, the configuration in these sections would be overwritten by the configuration files in other modules.

so let us understand the XMl and its ELements ans tructure

Every Config.xml has following elements
modules global admin adminhtml install frontend default stores websites

The XML sub-structure of each element is described separately below.
1)Modules
<modules>
         <(NameSpace_ModuleName)>
             <active>[true|false]</active>
             <codePool>[core|community|local]</codePool>
             <depends>
                 <(AnotherNameSpace_ModuleName) />
             </depends>
             <version>(version_number)</version>
         </(NameSpace_ModuleName)>
    </modules>

active codePool depends version

Sunday, January 15, 2012

Magento How to Remove the Block through XML

Basically there are two ways to remove blocks in layout XML:
by using: <remove name="" />
by using: <action method="unsetChild">

Both are important to understand
<remove name="" /> will operate on a global context, after all the layouts are processed which means that it will remove the named layout block completely, regardless of which layout handle added it.

<action method="unsetChild"> operates on a localized context, specifically, in the context where you use it. So, if you want to remove a specific block from a specific layout handle and possibly insert it at another position or layout handle, you need to use this approach.

Let us understand with example
Use remove
<default>
    <!-- remove the language and store switcher and footer links blocks, we won't use them -->
    <remove name="top.menu" />
    <remove name="footer_links" />
</default>

Use unsetChild to move or rearrange blocks in your layout:
    <default>
        <!-- move the breadcrumb block from the top.bar child block back to the template root -->
        <reference name="top.bar">
            <action method="unsetChild"><name>breadcrumbs</name></action>
        </reference>

        <reference name="root">
            <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
        </reference>
    </default>

Sunday, January 8, 2012

Magento Add Static Block through XML or Phtml

We are assuming  that you know how to add the static block through admin.We can add the Static block in any page through two ways

Add through xml

<block type="cms/block" name="cms_test_block">
                <action method="setBlockId"><block_id>test_block</block_id></action>
</block>

Through phtml files

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(' test_block')->toHTMl(); ?>

LinkWithin

Blog has moved, searching new blog...