2016-03-22 16 views
0

Ich arbeite in Magento. Ich muss hinzufügen, dass einige Daten mithilfe der CSV-Datei importieren. Ich habe ein Modul im Backend mit dieser URL erstellt. http://inchoo.net/magento/getting-started-with-building-admin-module-in-magento/So rufen Sie die Vorlagendatei in meinem Controller auf?

Derzeit bekomme ich balnk Seite, wenn ich auf Artikel 1.Now Menü klicken Ich brauche eine Formulardatei erstellen Import Schaltfläche hinzufügen und Absenden-Button. Wenn der Benutzer auf Senden klickt, wird die Aktion gespeichert. Wie kann ich meine Vorlagendatei auf einer leeren Seite hinzufügen? Bitte helfen Sie.

Config.xml

<?xml version="1.0"?> 

<config> 
    <modules> 
     <ActiveCodeline_SampleModule1> 
      <version>0.1.0</version> 
     </ActiveCodeline_SampleModule1> 
    </modules> 


<global> 
     <helpers> 
      <SampleModule1> 
       <class>ActiveCodeline_SampleModule1_Helper</class> 
      </SampleModule1> 
     </helpers> 
</global>   


     <admin> 
     <routers> 
      <samplemodule1> 
       <use>admin</use> 
       <args> 
        <module>ActiveCodeline_SampleModule1</module> 
        <frontName>samplemodule1</frontName> 
       </args> 
      </samplemodule1> 
     </routers> 
    </admin> 



    <adminhtml> 
     <menu> 
      <menu1 translate="title" module="SampleModule1"> 
       <title>ActiveCodeline SampleModule1</title> 
       <sort_order>60</sort_order> 
       <children> 
        <menuitem1 module="SampleModule1"> 
         <title>Menu item 1</title> 
         <action>samplemodule1/example</action> 
        </menuitem1> 
       </children>     
      </menu1> 
     </menu> 
     <acl> 
      <resources> 
       <admin> 
        <children> 
         <menu1 translate="title" module="SampleModule1"> 
          <title>ActiveCodeline SampleModule1</title> 
          <sort_order>60</sort_order> 
          <children> 
           <menuitem1> 
            <title>Menu item 1</title> 
           </menuitem1> 
          </children> 
         </menu1> 
        </children> 
       </admin> 
      </resources> 
     </acl> 
     <layout> 
      <updates> 
       <itoris_dynamicproductoptions> 
        <file>activecodeline_samplemodule1.xml</file> 
       </itoris_dynamicproductoptions> 
      </updates> 
     </layout> 


    </adminhtml>  





</config> 

Layout/activecodeline_samplemodule1.xml

<?xml version="1.0"?> 
<layout version="0.1.0"> 
    <default> 
    </default> 
    <samplemodule1_example_index> 
     <reference name="content"> 
      <block type="core/template" name="samplemodule1" template="activecodeline/samplemodule1/custom_import.phtml" /> 
     </reference> 
    </samplemodule1_example_index> 
</layout> 

Antwort

0

Sie hinzufügen, müssen Sie das Layout-Update in config.xml

 <layout> 
      <updates> 
       <mymodule> 
        <file>mymodule.xml</file> 
       </mymodule> 
      </updates> 
     </layout> 

, nachdem Sie müssen hinzufügen Sie Layout-Datei B. mymodule.xml für das Paket/Thema im Admin-Design-Namespace, dir ectory layout

<?xml version="1.0"?> 
    <layout> 
     <modules_controller_action> 
      <reference name="content"> 
       <block type="core/template" template="mymodule/template.phtml" /> 
      </reference> 
     </modules_controller_action> 
    </layout> 

wo modules_controller_action Weg zu Ihnen Tätigkeit, mymodule/template.phtml Weg zu Ihnen Vorlage. Sie

Layout ändern
<layout> 
    <updates> 
     <samplemodul1> 
      <file>activecodeline_samplemodule1.xml</file> 
     </samplemodul1> 
    </updates> 
</layout> 

in Ihrer config.xml, weil Sie über Modul-Namensräume verwenden Dieser

+0

Wo muss ich meinen Modulordner und dieses Layout XML-Datei erstellen? –

+0

Ich habe samplemodule1.xml in meinem Layout-Ordner erstellt und einen Ordner in Vorlagen namens "samplemodule1" erstellt. In diesem Ordner erstellen Sie eine Datei custom_form.phtml. Aber es zeigt leere Seite in Admin. –

+0

Zeigen Sie das Code-Layout sampelmodule1.xml und config.xml im Modul, in Ihrer Frage. – Naumov

0

den Code in Ihrer config.xml

<layout> 
 
      <updates> 
 
       <itoris_dynamicproductoptions> 
 
        <file>activecodeline_samplemodule1.xml</file> 
 
       </itoris_dynamicproductoptions> 
 
      </updates> 
 
     </layout>

So brauchen Sie Erstellen einer Layout-Datei unter

app/design/adminhtml/frontend/default/layout/activecodeline_samplemodule1.xml

Für Template-Datei, wenn Sie planen adminhtml Vorlage dann app/design/adminhtml/Frontend/default/template/NAMEOFYOURMODULE/templatefile.phtml

Lassen Sie mich, wenn Sie wissen zu erstellen irgendeine Frage oder Zweifel

Dank

-1

Bitte überprüfen Sie unter zwei Controller-Funktion. Das Init-Layout wird Breadcrumbs und layout.xml darstellen.

protected function _initAction() { 
     $this->loadLayout(); 
     $this->getLayout()->getBlock("content")->setTitle($this->__("Page title")); 
     $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs"); 
     $breadcrumbs->addCrumb("home", array(
     "label" => $this->__("Home Page"), 
     "title" => $this->__("Home Page"), 
     "link" => Mage::getBaseUrl() 
      )); 
     $breadcrumbs->addCrumb("custommodule", array(
     "label" => $this->__("Custom Module"), 
     "title" => $this->__("Custom Module") 
      )); 
      return $this; 
    } 
     public function indexAction() 
     { 

        $this->_initAction(); 
        $this->renderLayout(); 
     } 
+0

Es sollte keine Logik, was auch immer in Controllern, sollten Sie einen Beobachter angeben und das Layout nach Ereignissen ändern – MagentoNinja

Verwandte Themen