2012-10-23 5 views
0

admin 패널 (사용자 정의 모듈)에 magento로 양식을 만들려고합니다. 지금은 내 magento 맞춤 모듈이 제대로 작동합니다. 관리자 패널에서 메뉴를 만들었습니다. 일부 컨트롤러를 다시 작성하지만 관리자 패널에서 양식을 만들 수 없습니다 (메뉴 항목을 클릭 할 때).Magento 관리자 패널에서 양식 만들기

<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> 

I 앱/디자인/프론트 엔드/기본/기본/레이아웃/skipcart.xml에있는 파일이 있습니다 config.xml에 나는 코드의 다음 부분이있다. 이 파일에서 내가 잘못 만들었습니다. 이 방법으로 magento가이 파일을 읽었는지 확인합니다. magento가 skipcart.xml을 읽으면 경고 : simplexml_load_string()을 반환하지만 magento는 오류를 반환하지 않습니다. 그리고 또 하나의 문제가 있습니다. adminhtml.xml의 config.xml에서이 코드를 메뉴로 이동하면 관리 패널의 메뉴가 사라집니다. Magento 1.7에서 모듈을 시험해 보았습니다. 아무도 나를 도울 수 있습니까?

내가 응용 프로그램/코드에 컨트롤러가/지역/MyNamespace에/Skipcart/컨트롤러/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.--> 
+0

Skipcart.xml는 - 자본 S 함께 ... 당신이 말하는 아래 내가 파일'[...] skipcart.xml.' (NO 자본 S) ... 내가 미안 – FlorinelChis

+0

이 단지 그 후 작은 글씨로 자본을 써 보았습니다. 이제 파일과 config.xml은 작은 글자로되어 있습니다. 이것은 잘못된 것이 아닙니다. | –

+0

'Skipcart.xml'에 대한 내용을 게시 할 수 있습니까? 또한 어떤 형식으로 표시하려고합니까? (컨트롤러 액션과 관련된 블록이 생성 되었습니까?) – FlorinelChis

답변

1

는 그냥 함수 본문을 변경 core/text 대신 아래처럼 전화하십시오 core/templatesetTemplate('filename.phtml'); 이 파일에서 양식 html을 추가해야합니다.

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

    //create a text block with the name of "example-block" 
    $block = $this->getLayout() 
    ->createBlock('core/template', 'example-block') 
    ->setTemplate('folder/fileName.phtml'); 

    $this->_addContent($block); 

    $this->_setActiveMenu('tutorial_menu/first_page');  

    $this->renderLayout(); 


} 
관련 문제