2013-06-04 42 views

回答

-2

請訪問此鏈接希望它有幫助。

Magneot System Configuration for Custom Module

+2

您的回答是可以的,但是請儘量避免將來使用鏈接回答,因爲鏈接可能會被破壞,因此您的回答對將來的讀者來說是沒用的:) – versvs

+2

鏈接被破壞了.... – Nano

+1

鏈接仍然是壞的。 – Jurik

1

它包括4個文件添加一個新的配置菜單的模塊。如果你的模塊已經有了一個輔助類Data.php,那麼只需要兩個xml文件。助手類Data.php可以是空的,只需在那裏加載管理面板中的新菜單配置即可。 最重要的兩個xml文件是adminhtml.xmlsystem.xml文件在您的模塊的etc文件夾中。

樣本adminhtml.xml

<?xml version="1.0" encoding="UTF-8"?> 
<config> 
    <acl> 
     <resources> 
      <admin> 
       <children> 
        <system> 
         <children> 
          <config> 
           <children> 
            <helloworld_setting> 
             <title>Hello World</title> 
            </helloworld_setting> 
           </children> 
          </config> 
         </children> 
        </system> 
       </children> 
      </admin> 
     </resources> 
    </acl> 
</config> 

樣本的system.xml

<?xml version="1.0" encoding="UTF-8"?> 
<config> 
    <tabs> 
     <helloworld translate="label" module="helloworld"> 
      <label>Hello World</label> 
      <sort_order>99999</sort_order> 
     </helloworld> 
    </tabs> 
    <sections> 
     <helloworld_setting translate="label" module="helloworld"> 
      <label>Settings</label> 
      <tab>helloworld</tab> 
      <frontend_type>text</frontend_type> 
      <sort_order>99</sort_order> 
      <show_in_default>1</show_in_default> 
      <show_in_website>1</show_in_website> 
      <show_in_store>1</show_in_store> 
      <groups> 
       <greeting_settings translate="label"> 
        <label>Greeting Settings</label> 
        <frontend_type>text</frontend_type> 
        <sort_order>1</sort_order> 
        <show_in_default>1</show_in_default> 
        <show_in_website>1</show_in_website> 
        <show_in_store>1</show_in_store> 
        <fields> 
         <enabled translate="label"> 
          <label>Enabled</label> 
          <frontend_type>select</frontend_type> 
          <source_model>adminhtml/system_config_source_yesno</source_model> 
          <sort_order>10</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>1</show_in_store> 
         </enabled> 
         <greeting translate="label,comment"> 
          <label>Greeting</label> 
          <frontend_type>text</frontend_type> 
          <sort_order>20</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>1</show_in_store> 
          <comment>Greeting text.</comment> 
         </greeting> 
        </fields> 
       </greeting_settings> 
      </groups> 
     </helloworld_setting> 
    </sections> 
</config> 

若要檢索您在配置菜單

//sectionName/groupName/fieldName 
echo Mage::getStoreConfig('helloworld_setting/greeting_settings/enabled'); 
echo Mage::getStoreConfig('helloworld_setting/greeting_settings/greeting'); 
設置的值

如果出現任何問題,請確保代碼更改後清除緩存,然後仔細檢查xml文件中是否存在拼寫錯誤。

相關問題