Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to call files with createBlock
    primarykey
    data
    text
    <p>I am following No_Frills_Magento_Layout by Alan Storm. I have got to a point that I could not make work by following what the book said so I went about it an alternate way</p> <p>Below is the books way and I get an error</p> <pre><code>$layout = Mage::getSingleton(’core/layout’); $block = $layout-&gt;createBlock('ts_nofrills/helloworld', 'root'); echo $block-&gt;toHtml(); //Fatal error: Call to a member function createBlock() on a non-object in </code></pre> <p>below is my way and produces the .phtml text </p> <pre><code>$main_block = new Ts_Nofrills_Block_Helloworld(); $layout = Mage::getSingleton(’core/layout’); $block = $layout-&gt;createBlock($main_block, 'root'); echo $block-&gt;toHtml(); </code></pre> <p>My problem is as the book continues this example is expanded on and by deviating from the example and doing it my way I dont feel like I am learning to the full potential.</p> <p>I guess I have written the first parameter incorrectly for magento to recognise it in the createBlock function what have i done wrong on example one?</p> <p>I have been reluctant to put this question on for two reasons:</p> <p>1 - Im sure the answer is in the book (I cant find it though)</p> <p>2 - Im sure this question has been asked on here (once again I have looked but cant find it)</p> <p>===EDIT===</p> <pre><code>&lt;global&gt; &lt;blocks&gt; &lt;Ts_Nofrills&gt; &lt;class&gt;Ts_Nofrills_Block&lt;/class&gt; &lt;/Ts_Nofrills&gt; &lt;/blocks&gt; .... &lt;/global&gt; </code></pre> <p>file structure</p> <ul> <li>Ts</li> <li><ul> <li>Nofrills</li> </ul></li> <li><ul> <li><ul> <li>Block</li> </ul></li> </ul></li> <li><ul> <li><ul> <li><ul> <li>Template.php</li> </ul></li> </ul></li> </ul></li> <li><ul> <li><ul> <li>controllers</li> </ul></li> </ul></li> <li><ul> <li><ul> <li><ul> <li>IndexController.php</li> </ul></li> </ul></li> </ul></li> <li><ul> <li><ul> <li>etc</li> </ul></li> </ul></li> <li><ul> <li><ul> <li><ul> <li>config.xml</li> </ul></li> </ul></li> </ul></li> </ul>
    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. 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