I am writing a module for magento1.9. Please help us set attributes for app / design / frontend / rwd / default / layout / kalinin_form.xml:

<?xml version="1.0" ?> <layout> <kalininform_index_index> <reference name="content"> <block type="kalininform/form" template="Kalinin_Form/index.phtml" /> </reference> </kalininform_index_index> </layout> 

As you can see, now my type attribute (and maybe others) is set incorrectly.

The problem is that the browser shows a page with an empty content area at localhost / magento3 / index.php / form

I cite the rest of the module code.

app / design / frontend / rwd / default / template / Kalinin_Form / index.phtml:

 <?php echo('qqqqqqqqqqqqq'); 

app / code / local / Kalinin / Form / controllers / IndexController.php:

 <?php class Kalinin_Form_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } } 

app / code / local / Kalinin / Form / Block / Form.php:

 <?php class Kalinin_Form_Block_Form extends Mage_Core_Block_Template { public function getNewsCollection() { Mage::log("Your Log Message"); return true; } } 

app / code / local / Kalinin / Form / etc / config.xml:

 <?xml version="1.0" ?> <config> <modules> <Kalinin_Form> <version>0.0.1</version> </Kalinin_Form> </modules> <frontend> <layout> <updates> <kalininform> <file>kalinin_form.xml</file> </kalininform> </updates> </layout> <routers> <kalininform> <use>standard</use> <args> <module>Kalinin_Form</module> <frontName>form</frontName> </args> </kalininform> </routers> </frontend> <global> <blocks> <Kalinin_Form> <class>Kalinin_Form_Block</class> </Kalinin_Form> </blocks> </global> </config> 

In general, I have a problem with understanding attributes in app / design / frontend / rwd / default / layout / kalinin_form.xml. No official documentation. I would be grateful if you explain what's what.

ps: nothing is written to system.log or exception.log

    1 answer 1

    In the first go rule config replacing it

     <global> <blocks> <Kalinin_Form> <class>Kalinin_Form_Block</class> </Kalinin_Form> </blocks> </global> 

    on this

     <global> <blocks> <kalininform> <class>Kalinin_Form_Block</class> </kalininform> </blocks> </global> 

    There is written not the name of the module and the key. Next, let's deal with the layout

     <layout> <kalininform_index_index> <!-- это ModuleName().'_'.ControllerName.'_'.ActionName --> <reference name="content"> <!-- обновляем контент --> <block type="kalininform/form" name="kalininform" template="Kalinin_Form/index.phtml" /> </reference> </kalininform_index_index> </layout> 

    Now let's look at the block section.

    type='kalininform/form is the type of the block when rendering inside Magento, call the getBlockSingleton method, and this kalininform/form key will be passed to it. nothing but this part:

      <global> <blocks> <kalininform> <class>Kalinin_Form_Block</class> </kalininform> </blocks> </global> 

    Of all the configs, he will select the class name by key, in our case it is Kalinin_Form_Block .

    The second part of the key is the path to the class name in lowercase mode, i.e. in our case, magento will take the form from the key and convert it to the Form and then take the previous class name (namespace implementation), it will substitute this piece to the end with the underscore, resulting in the final class of the Kalinin_Form_Block_Form block and it will load the next Kalinin\Form\Block\Form.php file Kalinin\Form\Block\Form.php .

    As for the template this is a relative path to the template in the template directory of the current theme. those. if template="Kalinin_Form/index.phtml" should be located in the directory template/Kalinin_Form/ .

    Further, you forgot about the name template in the context of the content block; in principle, this is not critical, but the identification of the blocks follows the name so it is better to register it.

    There are a few more options on which I will not dwell on this output , as , after , etc.

    Pattern debugging methods:

    1. Enable the display of paths to the templates система->конфигурация-> для разработчиков switch the store view in the left corner to the site store, then find the item templates and enable the подсказка путей шаблона подсказки классов шаблонов .
    2. Monitoring logs, tailf -1000 /magentoroot/var/log/exception.log and tailf -1000 /magentoroot/var/log/system.log where the magentoroot path to the root directory of magento.
    3. Monitoring server logs.
    4. Well, and more for magento itself, copy the file /magentoroot/errors/local.xml.sample to /magentoroot/errors/local.xml if it doesn’t exist, or bring it to the form

      default print

    for development environment estevstvenno.