0

Can we write a block tag in our layout without its type parameter, such as below

<block  name="formInput" template="Pfay/UserForm/FormInput.phtml" />

what is the other way to do this if i don't have any block associated to my template file ?

  • if you don't have any block type then you can write <block type="core/template" name="formInput" template="Pfay/UserForm/FormInput.phtml" /> – Keyur Shah Jan 23 '14 at 11:36
  • This will also be helpful to get an understanding about the type parameter of blocks stackoverflow.com/questions/6633307/… – Sukeshini Jan 23 '14 at 11:44
  • @Sukeshini, thanks, the link was really helpful. – user3151033 Jan 23 '14 at 11:53
5

type attribute is mandatory. Or you can use class attribute instead of type, but both of same thing:

<block class="core/template" name="left.permanent.callout" template="callouts/left_col.phtml">
  ...
</block>

or

<block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml">
      ...
</block>

See this line (/app/code/core/Mage/Core/Model/Layout.php):

protected function _generateBlock($node, $parent)
{
        if (!empty($node['class'])) {
            $className = (string)$node['class'];
        } else {
            $className = (string)$node['type'];
        }
        //....
}
2

as you want to use a template, you have to use a type, which supports templates. The most generic type you can use for this is core/template

As already said, you have to use a type, because there is no default type. On the other side there are a lot of blocks, which dont even support templates.

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.