Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a simplified version of what's going on, but will hopefully be enough to get you going.</p> <h2>Special Objects</h2> <p>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 <em>class aliases</em> . So this</p> <pre><code>page/html </code></pre> <p>corresponds to the Block class</p> <pre><code>Mage_Page_Block_Html </code></pre> <p>Class here is referring to PHP classes, not CSS classes.</p> <h2>Magento Page Rendering</h2> <p>A Layout Object is responsible for creating all the HTML for a Magento page.</p> <p>A Layout Object is a collection of nested Block Objects.</p> <p>Most Block Objects are Template Blocks, that is, the Block class inherits from the base Magento template block <code>Mage_Core_Block_Template</code>. Template Blocks are objects responsible for rendering a phtml template file.</p> <p>So, when you specify a "type" in the XML Layout files, you're telling Magento.</p> <blockquote> <p>I want to add a block object with the class foo/bar, using the template baz.phtml</p> </blockquote> <p>In code, that's </p> <pre><code>&lt;!-- "name" and "as" are used to identify the block in the layout, so that PHP code can get a reference to the object. --&gt; &lt;block type="foo/bar" name="myname" as="myname" template="path/to/baz.phtml" /&gt; </code></pre> <p>If all you want to do is render a template file, you can use</p> <pre><code>type="core/template" </code></pre> <p>However, by using a different value, like</p> <pre><code>type="page/html" </code></pre> <p>your phtml template file gets access to all the methods in</p> <pre><code>Mage_Page_Block_Html </code></pre> <p>Which means you could do something like</p> <pre><code>File: template.phtml &lt;a href="&lt;?php echo $this-&gt;getBaseUrl();?&gt;"&gt;&lt;/a&gt; </code></pre> <p>The <code>core/template</code> class doesn't have a <code>getBaseUrl</code> method, but the <code>page/html</code> class does. </p> <p>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, <code>page/html</code> is a decent default. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload