I always have challenges identifying the proper handles for everything, so please bear with me here. I've scoured Google, SE, and tried myriad variations, with no luck. (And yes, I've used techniques here: Debugging Layout Loading, but am unsure what to do with the output.
The Problem: The controller loads. The layout does not.
When I visit the page at localhost/magento/mymodule/ajax/cart
It echos 'HERE!'. The var_dump of the getLayouts generates:
array(4) { [0]=> string(17) "mymodule_ajax_cart" [1]=> string(13) "STORE_default" [2]=> string(24) "THEME_frontend_theme_theme" [3]=> string(19) "customer_logged_out" } The Code
Custom controller:
app/code/local/mycompany/mymodule/controllers/AjaxController.php
class Mycompany_Mymodule_AjaxController extends Mage_Core_Controller_Front_Action { public function cartAction() { echo 'HERE!'; $this->loadLayout('mymodule_ajax_cart'); var_dump($this->getLayout()->getUpdate()->getHandles()); $this->renderLayout(); } } Config file:
app/code/local/mycompany/mymodule/etc/config.xml
<config> <modules> <mycompany_mymodule> <version>1.0.0</version> </mycompany_mymodule> </modules> <global> <helpers> <mymodule> <class>Mycompany_Mymodule_Helper</class> </mymodule> </helpers> </global> <frontend> <routers> <mymodule> <use>standard</use> <args> <module>Mycompany_Mymodule</module> <frontName>mymodule</frontName> </args> </mymodule> </routers> <layout> <updates> <mymodule> <file>mymodule.xml</file> </mymodule> </updates> </layout> </frontend> </config> Layout file at
app/design/frontent/base/default/layout/mymodule.xml
<?xml version="1.0"?> <layout> <mymodule_ajax> <block type="core/text_list" name="content" output="toHtml" as="content" /> </mymodule_ajax> <mymodule_ajax_cart> <reference name="content"> <block type="core/template" template="mymodule/ajaxcart.phtml" /> </reference> </mymodule_ajax_cart> </layout> And finally, the template file at
app/design/frontend/theme/theme/template/mymodule/ajaxcart.phtml
<div style="border: 2px solid red"> Hello world </div> Please advise. I know I'm missing something obvious, but cannot for the life of me find it.
mycompany_mymoduleprefix in every handle ? (mycompany_mymodule_ajaxfor instance).mycompany_mymodule(first handle). Every xml tag that has the prefixmymodulewithout themycompany_prefix is bad IMHO. You should change all tag names to have the prefixmycompany_beforemymodule.