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
Magento block is a modular unit of content that can be placed anywhere on the page. Blocks in Magento are referred to as static blocks or CMS blocks. They help to display fixed information such as text, images, and embedded video, as well as dynamic information from a widget that originates through the database.
Magento 2 Template Paths. You would then set the path to the template inside the <argument> node. This is a handy way to make UI-related customizations, without having to create a new block. As any Magento developer could tell you, the path to your template in Magento 1 is pretty straightforward.
Dynamic view files These are: . less files, templates, and layouts.
This is a simplified version of what's going on, but will hopefully be enough to get you going.
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
page/html
corresponds to the Block class
Mage_Page_Block_Html
Class here is referring to PHP classes, not CSS classes.
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.
I want to add a block object with the class foo/bar, using the template baz.phtml
In code, that's
<!-- "name" and "as" are used to identify the block in the layout, so that
PHP code can get a reference to the object. -->
<block type="foo/bar" name="myname" as="myname" template="path/to/baz.phtml" />
If all you want to do is render a template file, you can use
type="core/template"
However, by using a different value, like
type="page/html"
your phtml template file gets access to all the methods in
Mage_Page_Block_Html
Which means you could do something like
File: template.phtml
<a href="<?php echo $this->getBaseUrl();?>"></a>
The core/template
class doesn't have a getBaseUrl
method, but the page/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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With