1

This is about block type which I don't know exactly.

<block type="A/B" name="root" output="toHtml" template="">

What is "A/B" as block type there?

Any help appreciated.

1

type="A/B" here A is for Module name and B is for class name of that module(A).

It can be denoted that A refers to => page <=> Mage_Page_Block Which is declared at app/code/core/Mage/Page/etc/config.xml

And B refers to => html => Mage_Page_Block_Html Class as well as declared at app/code/core/Mage/Page/Block/Html.php

Hope this helps. :-)

1

Here A is a class group of Block for example core, page etc. Class group is a node between <block> and <class> i.e. <testing_contact> in following example.

if you consider for you custom module then whatever the class group you have mentioned in your configuration is the part of A.

for example suppose you config file is as bellow.

<?xml version="1.0" encoding="UTF-8" ?>
    <config>
        <global>
           <blocks>
              <testing_contact>
                  <class>Testing_Contact_Block</class>
               </testing_contact>
           </blocks>
       </global>
    </config>

Then in this case your A is testing_contact.

and as far as B is concern it is simply a file under Block directory.

so for above example if we say <block type="testing_contact/product" />

then product is a file which is available under Testing/Contact/Block directory.

This directory is find by <class>Testing_Contact_Block</class>

So if we consider any core example lets say <block type="cms/block" /> then for this if we look at a config file of cms module located at app\code\core\Mage\Cms\etc\config.xml here you will get a code like

        <blocks>
            <cms>
                <class>Mage_Cms_Block</class>
            </cms>
        </blocks>

so your A is cms and B is block and if you look at app\code\core\Mage\Cms\Block you will get a file with this name.

Hope this will help you to understand.

0

Magento Bloks are built by three parts.

The first part is the layout, here you specify where the block is going to be added.

The second part is the template, this is phtml file (html with php) where you are suppose to only add what is going to be displayed.

The last part an the one that must be added in that "type" is the block class. This class contains the code that is not planed to display something and allows you to set things like the template (second part) that must be render.

This class will extend a block class from magento core.

Imagine that you need to use parameter from the configuration and display those parameters in any place.

You will have: A layout to add the block. A block class that extends Mage_Core_Block_Template and implements getConfig and initializes $_template with the path to the template(phtml) A template that will use the getConfig to get the config values and display it.

The type attribute points to the block class. The reference must be done in the magento way to point files. I mean in the config.xml you need to add a blocks like this:

    <blocks>
        <NAMEBLOCK>
            <class>COMPANY_PLUGINNAME_Block</class>
        </NAMEBLOCK>
    </blocks>

and after refer it as "NAMEBLOCK_NAMEFILEWITHOUTEXTENSION"

After you need to add the block class file to the path COMPANY/PLUGINNAME/Block/NAMEFILEWITHOUTEXTENSION.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.