Magento: rendering a blank page when calling a template from Ajax

First of all, I must apologize for the lack of knowledge on this issue. I am still new to Magento, and with the information I came across I should get this job. I started with here . I can get the Ajax method to call, but I get empty 2column-left.phtml as my output (so I see the header, left column, empty main column and footer). I have my files installed like this:

app / local / MyModule / Featured / Block / Featured.php

<?php  
class MyModule_Featured_Block_Featured extends Mage_Core_Block_Template  
{  
    public function __construct()  
    {  
        $this->_controller = 'featured';  
        $this->_blockGroup = 'featured';  
        parent::__construct();  
    }  
}  
?>

app / local / MyModule / Featured / controllers / FeaturedController.php

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

app / local / MyModule / Featured / etc / config.xml

<config>
    <modules>
        <MyModule_Featured>
            <version>0.1.0</version>
        </MyModule_Featured>
    </modules>
    <frontend>
        <routers>
            <featured>
                <use>standard</use>
                <args>
                    <module>MyModule_Featured</module>
                    <frontName>featured</frontName>
                </args>
            </featured>
        </routers>
    </frontend>
</config>

app / design / frontend / default / myLayout / layout / local.xml

<config>
    <featured_featured_display>
        <block type="module/block" name="root" output="toHtml" template="catalog/product/featured.phtml" />
    </featured_featured_display>
</config>

Ajax code on phtml homepage:

var url = "<?php echo $this->getUrl('featured/featured/display') ;?>";
jQuery(document).ready(function() {
    jQuery('#featured-products').load(url);
});
+3
2

, node <layout>, <config>.

< > P.S.
jQuery - - Magento Prototype .

var url = "<?php echo $this->getUrl('featured/featured/display') ?>";
document.observer('dom:loaded', function(){
    new Ajax.Updater('featured-products', url);
});

>

+4

, , , . node, node.

0

Source: https://habr.com/ru/post/1793987/


All Articles