0

Im using this module. In admin i have in the top menu two items: Add new testimonials and Manage testimonials. When I clicked on this two im getting a 404 page.

this is indexController code :

class MageZone_Testimonial_IndexController extends Mage_Core_Controller_Front_Action {

    public function indexAction() {
        //$this->loadLayout();
        //$this->_initLayoutMessages('testimonial/session');
        //$this->renderLayout();
        echo 1; exit ();
    }

    public function _getSession() {
        return Mage::getSingleton('testimonial/session');
    }
}

I tried to exit, but im still getting the 404; this is etc/config.xml file content:

<?xml version="1.0" encoding="utf-8"?>
<!--
/**
 * @version     $Id$
 * @author      Pham Minh Tuan ([email protected])
 * @category    MageZone
 * @package     MageZone_Testimonial
 * @copyright   Copyright (c) 2011 MageZone (http://www.magezone.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
 -->

<config>
    <modules>
        <MageZone_Testimonial>
            <version>2.0.3</version>
        </MageZone_Testimonial>
    </modules>

    <frontend>
        <routers>
            <testimonial>
                <use>standard</use>
                <args>
                    <module>MageZone_Testimonial</module>
                    <frontName>testimonial</frontName>
                </args>
            </testimonial>
        </routers>

        <translate>
            <modules>
                <MageZone_Testimonial>
                    <files>
                        <default>MageZone_Testimonial.csv</default>
                    </files>
                </MageZone_Testimonial>
            </modules>
        </translate>

        <layout>
            <updates>
                <testimonial>
                    <file>testimonial.xml</file>
                </testimonial>
            </updates>
        </layout>
    </frontend>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <testimonial>MageZone_Testimonial_Adminhtml</testimonial>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

    <adminhtml>
        <layout>
            <updates>
                <testimonial>
                    <file>testimonial.xml</file>
                </testimonial>
            </updates>
        </layout>

        <translate>
            <modules>
                <MageZone_Testimonial>
                    <files>
                        <default>MageZone_Testimonial.csv</default>
                    </files>
                </MageZone_Testimonial>
            </modules>
        </translate>
    </adminhtml>

    <global>
        <models>
            <testimonial>
                <class>MageZone_Testimonial_Model</class>
                <resourceModel>testimonial_mysql4</resourceModel>
            </testimonial>
            <testimonial_mysql4>
                <class>MageZone_Testimonial_Model_Mysql4</class>
                <entities>
                    <testimonial>
                        <table>magezone_testimonial_testimonial</table>
                    </testimonial>
                </entities>
            </testimonial_mysql4>
        </models>

        <resources>
            <testimonial_setup>
                <setup>
                    <module>MageZone_Testimonial</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </testimonial_setup>

            <testimonial_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </testimonial_write>

            <testimonial_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </testimonial_read>
        </resources>

        <blocks>
            <testimonial>
                <class>MageZone_Testimonial_Block</class>
            </testimonial>
        </blocks>

        <helpers>
            <testimonial>
                <class>MageZone_Testimonial_Helper</class>
            </testimonial>
        </helpers>
    </global>

    <default>
        <testimonial>
            <general>
                <enable_frontend>1</enable_frontend>
                <enable_guest>1</enable_guest>
                <auto_approve>1</auto_approve>
                <show_website_name>1</show_website_name>
                <show_website_url>1</show_website_url>
            </general>
            <sidebar>
                <jquery>1</jquery>
                <limit>5</limit>
                <slide_time>5000</slide_time>
                <position>2</position>
            </sidebar>
        </testimonial>
    </default>
</config>

and this is the etc/adminhtml.xml

<?xml version="1.0" encoding="utf-8"?>
<!--
/**
 * @version     $Id$
 * @author      Pham Minh Tuan ([email protected])
 * @category    MageZone
 * @package     MageZone_Testimonial
 * @copyright   Copyright (c) 2011 MageZone (http://www.magezone.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
 -->

<config>
    <menu>
        <magezone>
            <title>MageZone Extensions</title>
            <sort_order>71</sort_order>
            <children>
                <testimonial module="testimonial">
                    <title>MageZone Testimonial</title>
                    <sort_order>71</sort_order>
                    <children>
                        <testimonial_new module="testimonial">
                            <title>Add New Testimonial</title>
                            <sort_order>1</sort_order>
                            <action>adminhtml/testimonial_testimonial/new</action>
                        </testimonial_new>
                        <testimonial module="testimonial">
                            <title>Manage Testimonials</title>
                            <sort_order>2</sort_order>
                            <action>adminhtml/testimonial_testimonial/index</action>
                        </testimonial>
                        <testimonial_config module="testimonial">
                            <title>Configuration</title>
                            <sort_order>999</sort_order>
                            <action>adminhtml/system_config/edit/section/testimonial</action>
                        </testimonial_config>
                    </children>
                </testimonial>
            </children>
        </magezone>
    </menu>

    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <MageZone_Testimonial>
                        <title>Testimonial Module</title>
                        <sort_order>10</sort_order>
                    </MageZone_Testimonial>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <testimonial translate="title">
                                        <title>MageZone Testimonial</title>
                                        <sort_order>50</sort_order>
                                    </testimonial>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>

admin controller:

<?php
/**
 * @version     $Id$
 * @author      Pham Minh Tuan ([email protected])
 * @category    MageZone
 * @package     MageZone_Testimonial
 * @copyright   Copyright (c) 2011 MageZone (http://www.magezone.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
 * Testimonial Adminhtml controller
 *
 * @category    MageZone
 * @package     MageZone_Testimonial
 * @author      Pham Minh Tuan ([email protected])
 */
class MageZone_Testimonial_Adminhtml_Testimonial_TestimonialController extends Mage_Adminhtml_Controller_Action {

    protected function _initAction() {
        $this->loadLayout()
            ->_setActiveMenu('magezone/testimonial/testimonial')
            ->_addBreadcrumb(Mage::helper('testimonial')->__('Testimonial Manager'),
                            Mage::helper('testimonial')->__('Testimonial Manager'));

        return $this;
    }

    protected function _setTitle() {
        return $this->_title($this->__('MageZone Testimonial'))->_title($this->__('Testimonial'));
    }

    public function indexAction() {
        $this->_setTitle();
        $this->_initAction();
        $this->renderLayout();
    }

    public function gridAction() {
        $this->getResponse()->setBody(
            $this->getLayout()->createBlock('testimonial/adminhtml_testimonial_grid')->toHtml()
        );
    }

    public function editAction() {
        $this->_setTitle();
        $testimonialId      = $this->getRequest()->getParam('id');
        $testimonialModel   = Mage::getModel('testimonial/testimonial')->load($testimonialId);

        if ($testimonialModel->getId() || $testimonialId == 0) {
            Mage::register('testimonial_data', $testimonialModel);
            $this->loadLayout();
            $this->_setActiveMenu('magezone/testimonial/testimonial');
            $this->_addBreadcrumb(Mage::helper('testimonial')->__('Testimonial Manager'),
                                Mage::helper('testimonial')->__('Testimonial Manager'));
            $this->_addBreadcrumb(Mage::helper('testimonial')->__('Testimonial Description'),
                                Mage::helper('testimonial')->__('Testimonial Description'));
            $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
            $this->_addContent($this->getLayout()->createBlock('testimonial/adminhtml_testimonial_edit'))
                ->_addLeft($this->getLayout()->createBlock('testimonial/adminhtml_testimonial_edit_tabs'));
            $this->renderLayout();
        } else {
            Mage::getSingleton('adminhtml/session')->addError(Mage::helper('testimonial')->__('Testimonial does not exist'));
            $this->_redirect('*/*/');
        }
    }

    public function newAction() {
        $this->_forward('edit');
    }

    public function saveAction() {
        if ($this->getRequest()->getPost()) {
            try {
                $postData           = $this->getRequest()->getPost();
                $testimonialModel   = Mage::getModel('testimonial/testimonial');
                if ($this->getRequest()->getParam('id') <= 0) {
                    $testimonialModel->setCreatedTime(Mage::getSingleton('core/date')->gmtDate());
                }

                // security fix
                $testimonial        = $postData['testimonial'];
                $testimonial        = Mage::helper('core')->htmlEscape($testimonial);
                $postData['testimonial']    = $testimonial;

                $testimonialModel->addData($postData)
                                ->setUpdateTime(Mage::getSingleton('core/date')->gmtDate())
                                ->setId($this->getRequest()->getParam('id'))
                                ->save();
                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('testimonial')->__('Testimonial was successfully saved'));
                Mage::getSingleton('adminhtml/session')->setTestimonialData(false);

                // check if 'Save and Continue'
                if ($this->getRequest()->getParam('back')) {
                    $this->_redirect('*/*/edit', array('id' => $testimonialModel->getId()));
                    return;
                }

                // go to grid
                $this->_redirect('*/*/');
                return;

            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                Mage::getSingleton('adminhtml/session')->setTestimonialData($this->getRequest()->getPost());
                $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));

                return;
            }
        }

        $this->_redirect('*/*/');
    }

    public function deleteAction() {
        if ($this->getRequest()->getParam('id') > 0) {
            try {
                $testimonialModel   = Mage::getModel('testimonial/testimonial');
                $testimonialModel->setId($this->getRequest()->getParam('id'))->delete();
                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('testimonial')->__('testimonial was successfully deleted'));
                $this->_redirect('*/*/');
            } catch (Exception $e) {
                Mage::getSingleton('adminihtml/session')->addError($e->getMessage());
                $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
            }
        }

        $this->_redirect('*/*/');
    }

    public function massDeleteAction() {
        $ids    = $this->getRequest()->getParam('testimonial');
        if (!is_array($ids)) {
            Mage::getSingleton('adminhtml/session')->addError(Mage::helper('testimonial')->__('Please select testimonial(s)'));
        } else {
            try {
                foreach ($ids as $id) {
                    $testimonial = Mage::getModel('testimonial/testimonial')->load($id);
                    $testimonial->delete();
                }

                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('testimonial')->__('Total of %d testimonial(s) were successfully deleted', count($ids)));

            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
            }
        }

        $this->_redirect('*/*/');
    }

    public function massStatusAction() {
        $ids    = $this->getRequest()->getParam('testimonial');
        if (!is_array($ids)) {
            Mage::getSingleton('adminhtml/session')->addError(Mage::helper('testimonial')->__('Please select testimonial(s)'));
        } else {
            try {
                foreach ($ids as $id) {
                    $testimonial = Mage::getModel('testimonial/testimonial')
                            ->load($id)
                            ->setStatus($this->getRequest()->getParam('status'))
                            ->setIsMassupdate(true)
                            ->save()
                    ;
                }

                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('testimonial')->__('Total of %d testimonial(s) were successfully updated', count($ids)));
            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
            }
        }

        $this->_redirect('*/*/');
    }
}

This is the path from the module : enter image description here so, any ideea why is this not working ?

8
  • You posted the frontend controller. There should be one for admin.
    – Marius
    Jul 9, 2014 at 8:40
  • pls check my post again Jul 9, 2014 at 8:45
  • Clear var/cache, log out and re-log into admin panel, then click on those items. Jul 9, 2014 at 8:46
  • I tried this already, but still nothing Jul 9, 2014 at 8:49
  • check my post again and see the path from the module in the pic Jul 9, 2014 at 8:51

1 Answer 1

1

Try setting up admin router by using the before attribute on the node. You can use the default code for an example, widgets is a good one.

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <widget before="Mage_Adminhtml">Mage_Widget_Adminhtml</widget>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.