Magento の管理パネル (カスタム モジュール) でフォームを作成しようとしています。今のところ、私の magento カスタム モジュールは正常に動作します。管理パネルでメニューを作成し、いくつかのコントローラーを書き直しましたが、管理パネルでフォームを作成できません (メニュー項目をクリックすると)。config.xml には、コードの次の部分があります。
<admin>
<routers>
<test>
<use>admin</use>
<args>
<module>Mynamespace_Skipcart</module>
<frontName>Skipcart</frontName>
</args>
</test>
</routers>
</admin>
<adminhtml>
<menu>
<tutorial_menu translate="title" module="skipcart">
<title>Skip Cart</title>
<sort_order>9999</sort_order>
<children>
<first_page module="skipcart">
<title>Our First Page</title>
<action>Skipcart/Adminhtml_index/index</action>
</first_page>
</children>
</tutorial_menu>
</menu>
<layout>
<updates>
<skipcart>
<file>Skipcart.xml</file>
</skipcart>
</updates>
</layout>
</adminhtml>
app/design/frontend/default/default/layout/skipcart.xml にファイルがあります。このファイルでは、私は間違って作成しました。この方法で、magento がこのファイルを読み取ったかどうかを確認します。magento が skipcart.xml を読み取ると、Warning: simplexml_load_string() が返されますが、magento はエラーを返しません。そして、もう1つ問題があります。メニューのこのコードを config.xml から adminhtml.xml に移動すると、管理パネルのメニューが消えます。モジュールをmagento 1.7で試しています。誰でも私を助けることができますか?
app/code/local/Mynamespace/Skipcart/controllers/Adminhtml/IndexController.php にコントローラーがあります。
<?php
class Mynamespace_Skipcart_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
public function indexAction()
{
$this->loadLayout();
//create a text block with the name of "example-block"
$block = $this->getLayout()
->createBlock('core/text', 'example-block')
->setText('<h1>This is a text block</h1>');
$this->_addContent($block);
//add menu active
$this->_setActiveMenu('tutorial_menu/first_page');
// $model = Mage::getModel('skipcart/skipcart'); Mage::log('da');
// $this->_setActiveMenu('system/another_menu_from_us');
// echo $block1 = $this->getLayout()->createBlock('skipcart/add');
// $this->_addContent($block1);
$this->renderLayout();
}
public function postAction()
{
$post = $this->getRequest()->getPost();
try {
if (empty($post)) {
Mage::throwException($this->__('Invalid form data.'));
}
/* here's your form processing */
$message = $this->__('Your form has been submitted successfully.');
Mage::getSingleton('adminhtml/session')->addSuccess($message);
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
$this->_redirect('*/*');
}
}
?>
およびskipcart.xml:
<?xml version="1.0"?>
<layout>
<skipcart_adminhtml_index_index>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<update handle="skipcart_index_index"/>
<reference name="content">
<block type="adminhtml/template" name="skipcart" template="skipcart/add.phtml"/>
</reference>
</skipcart_adminhtml_index_index>
<!-- I miss the <layout> because I want to check if magento read this file.-->