簡體   English   中英

Magento-布局文件不適用於自定義模塊

[英]Magento - Layout file not working for custom module

我正在為帶有電子郵件表單的頁面創建自定義模塊。 一切似乎都正常,但我無法使布局更新正常工作。 這是我的第一個自定義模塊,因此任何幫助都會很大。 謝謝。

應用程序/代碼/本地/Adtrak/ArrangeSurvey/ect/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <adtrak_arrangesurvey>
            <version>0.1.0</version>
        </adtrak_arrangesurvey>
    </modules>
    <global>
        <rewrite>
            <adtrak_arrangesurvey>
                <from><![CDATA[#^/arrangesurvey/#]]></from>
                <to>/adtrakArrangeSurvey/</to>
            </adtrak_arrangesurvey>
        </rewrite>
    </global>
    <frontend>
        <routers>
            <adtrak_arrangesurvey>
                <use>standard</use>
                <args>
                    <module>Adtrak_ArrangeSurvey</module>
                    <frontName>adtrakArrangeSurvey</frontName>
                </args>
            </adtrak_arrangesurvey>
        </routers>
        <layout>
            <updates>
                <adtrak_arrangesurvey>
                    <file>adtrakArrangeSurvey.xml</file>
                </adtrak_arrangesurvey>
            </updates>
        </layout>
    </frontend>
</config>

應用/設計/前端/ doorfit /默認/布局/adtrakArrangeSurvey.xml

<?xml version="1.0"?>
<layout version="0.1.0">

<adtrak_arrangesurvey_index_index>
    <label>Arrange A Survey</label>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
            <action method="setHeaderTitle" translate="title" module="arrangesurvey"><title>Arrange A Survey</title></action>
        </reference>
        <reference name="content">
            <block type="core/template" name="surveyForm" template="arrangesurvey/index.phtml"/>
        </reference>
    </adtrak_arrangesurvey_index_index>

    <adtrak_arrangesurvey_thanks_index>
        <label>Thank You</label>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
            <action method="setHeaderTitle" translate="title" module="contacts"><title>Thank You</title></action>
        </reference>
        <reference name="content">
            <block type="core/template" name="surveyForm" template="arrangesurvey/thanks.phtml"/>
        </reference>
    </adtrak_arrangesurvey_thanks_index>
</layout>

應用程序/代碼/本地/Adtrak/ArrangeSurvey/controllers/IndexController.php

我在此處插入了表單塊,因為我無法使布局文件正常工作,因此希望以后可以將其刪除。

require_once'Mage / Contacts / controllers / IndexController.php';

class Adtrak_ArrangeSurvey_IndexController extends Mage_Contacts_IndexController
{

   public function indexAction()
    {
        $this->loadLayout();

        $block = $this->getLayout()->createBlock(
        'Mage_Core_Block_Template',
        'arrangesurvey.form',
        array('template' => 'arrangesurvey/index.phtml')
        );


        $this->getLayout()->getBlock('content')->append($block);

        $this->renderLayout();

    }

    public function postAction()
    {
      Mage::log('postAction rewritten');
        $post = $this->getRequest()->getPost();
        if ( $post ) {
            $translate = Mage::getSingleton('core/translate');
            /* @var $translate Mage_Core_Model_Translate */
            $translate->setTranslateInline(false);
            try {
                $postObject = new Varien_Object();
                $postObject->setData($post);

                $error = false;

                if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
                    $error = true;
                }

                if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
                    $error = true;
                }

                if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
                    $error = true;
                }
                if ($error) {
                    throw new Exception();
                }
                $mailTemplate = Mage::getModel('core/email_template');
                /* @var $mailTemplate Mage_Core_Model_Email_Template */
                $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                    ->setReplyTo($post['email'])
                    ->sendTransactional(
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                        null,
                        array('data' => $postObject)
                    );

                if (!$mailTemplate->getSentSuccess()) {
                    throw new Exception();
                }

                $translate->setTranslateInline(true);

                $this->_redirect('arrangesurvey/thanks');

                return;
            } catch (Exception $e) {
                $translate->setTranslateInline(true);

                Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
                $this->_redirect('*/*/');
                return;
             }

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

}

任何幫助或建議都很好。

嘗試更換

<adtrakArrangeSurvey_index_index>

<Adtrak_ArrangeSurvey_index_index>

可能還有另一個錯誤。 但這是我第一次遇見

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM