TT120 February 2016

Custom Module Page Not Rendering Template - Magento

I'm developing a custom module for a new form (nothing fancy). I've created a custom template and I'm trying to render through my controller (I've tried XML too but that didn't work) using:

$this->loadLayout();
$this->getLayout()->getBlock('blockName');
$this->renderLayout();

But when I go to the page I get the site's header and footer etc. but not the content.

Here are my files:

IndexController.php

<?php    
    class Class_Module_IndexController extends Mage_Core_Controller_Front_Action {
        public function preDispatch() {
            parent::preDispatch();
            $this->getLayout()->getUpdate()->addHandle('module_default');
        }
        public function indexAction() {
            $this->loadLayout();
            $this->getLayout()->getBlock('blockName');
            $this->renderLayout();
        }
        public function postAction() {
            $_post = $this->getRequest()->getPost();
            // form fields
            $_name        = $_post['name'];
            $_to          = $_post['email'];
            $_phoneModel  = $_post['phone_model'];
            $_phoneNumber = $_post['phone_number'];
            $_issue       = $_post['issue'];
            // email set up
            $_subject = 'A Subject';
            $_message = 'Hey, ' . $_name . 'said that there phone (' . $_phoneModel . ') has the following issue:';
            $_message .= $_issue;
            $_message .= 'Their number is ' . $_phoneNumber;
            // magento mail set up
            $_mail = Mage::getModel('core/email');
            $_mail->setToName($_name);
            $_mail->setToEmail($_to);
            $_mail->setBody($_message);
            $_mail->setSubject($_subject);
            // send mail
            try {
                $_mail->send();
                Mage::getSingleton('customer/session')->addSuccess('Email sent successfull        

Answers


kuba_ceg February 2016

Weird way of defining layout (in config.xml). I've never seen something like this :D Maybe try define layout in standard way with separate xml file, here http://www.webspeaks.in/2010/07/create-your-first-magento-module.html You have tutorial. Since 5 years I make modules like that and it work :)

Post Status

Asked in February 2016
Viewed 3,435 times
Voted 13
Answered 1 times

Search




Leave an answer