I'm working on a custom Magento (1.3) theme and am wanting to add a left column.
I've created template/page/html/left.phtml with the html in.
In 2columns-left.phtml, i've added the following:
<?php echo $this->getChildHtml('left'); ?>
In page.xml, i've added the following:
<block type="page/html" name="left" as="left" template="page/html/left.phtml" />
What i'm not quite understanding is what that block type should be – it seems to work if I do page/html, core/template or page/html_header – what is this for and what is the correct value for this case, where I just want to effectively include a phtml file – page/html/left.phtml etc.
Thanks,
Ian
Best Answer
This is a simplified version of what's going on, but will hopefully be enough to get you going.
Special Objects
There are three types of Objects that Magento considers "special". These are Models, Blocks, and Helpers. Rather than use class names for these objects Magento uses URI-like strings called class aliases . So this
corresponds to the Block class
Class here is referring to PHP classes, not CSS classes.
Magento Page Rendering
A Layout Object is responsible for creating all the HTML for a Magento page.
A Layout Object is a collection of nested Block Objects.
Most Block Objects are Template Blocks, that is, the Block class inherits from the base Magento template block
Mage_Core_Block_Template
. Template Blocks are objects responsible for rendering a phtml template file.So, when you specify a "type" in the XML Layout files, you're telling Magento.
In code, that's
If all you want to do is render a template file, you can use
However, by using a different value, like
your phtml template file gets access to all the methods in
Which means you could do something like
The
core/template
class doesn't have agetBaseUrl
method, but thepage/html
class does.If you're doing custom module development (as opposed to just theming), I usually create a Block Object in my own module that extends one of the base Magento blocks. This allows me to add my own methods to the block as I see fit. If you're only theming,
page/html
is a decent default.