2014-06-18 45 views
0

故事

我搜索了一個解決方案,但沒有找到我能找到的解決方案,我是製作Magento模塊的新手,作爲一個開始,我試圖創建title屬性的一個非常簡單的改變。簡單的Magento模塊:更新佈局不起作用

問題

很簡單:它不起作用(標題屬性根本沒有改變)。我刷新了所有緩存,並確認模塊確實已在Config> Advanced> Advanced中加載。

代碼:

/app/etc/modules/Acme_NewCoolModule.xml:

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Acme_NewCoolModule> 
      <active>true</active> 
      <codePool>local</codePool> 
     </Acme_NewCoolModule> 
    </modules> 
</config> 

應用程序/代碼/本地/阿克米/ NewCoolModule的/ etc/config.xml文件:

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Acme_NewCoolModule> 
      <version>1.0.0.0</version> 
     </Acme_NewCoolModule> 
    </modules> 
    <frontend> 
     <layout> 
      <updates> 
       <Acme_NewCoolModule> 
        <file>acme_newcoolmodule.xml</file> 
       </Acme_NewCoolModule> 
      </updates> 
     </layout> 
    </frontend> 
</config> 

app/design/base/default/layout/acme_newcoolmodule.xml:

<?xml version="1.0"?> 
<layout> 
    <default> 
     <reference name="head"> 
      <action method="setTitle"><string>Hello World</string></action> 
     </reference> 
    </default> 
</layout> 

回答

0

Acme_NewCoolModule.xml代碼包含錯誤的配置

<config> 
    <modules> 
     <Acme_NewCoolModule> 
      <active>true</active> 
      <codePool>local</codePool> 
     </Acme_NewCoolModule> 
    </modules> 
</config> 

你有</Firtal_EnhancedEcommerce>和它<Firtal_NewCoolModule>,這是錯誤的。

我假設你namespaceAcme和模塊名稱是NewCoolModule

+0

對不起 - 我只是忘了將它從原來的改成它,它實際上是寫在你寫在這裏的。現在在OP中改變了它。 – Dencker

+0

@Dencker:編輯之後,你的Acme_NewCoolModule也是錯誤的。檢查關閉節點'' –

+0

感謝您的通知:) – Dencker

0

你在/app/etc/modules/Acme_NewCoolModule.xml代碼應該

/app/etc/modules/Acme_Newcoolmodule.xml

CODE:

1)替代

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Firtal_NewCoolModule> 
      <active>true</active> 
      <codePool>local</codePool> 
     </Firtal_EnhancedEcommerce> 
    </modules> 
</config> 

應該是:的

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Firtal_Newcoolmodule> 
      <active>true</active> 
      <codePool>local</codePool> 
     </Firtal_Newcoolmodule> 
    </modules> 
</config> 

2)代替app/code/local/Acme/NewCoolModule/etc/config.xml

應該是

app/code/local/Acme/Newcoolmodule/etc/config.xml

和配置代碼應該是

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Acme_Newcoolmodule> 
      <version>1.0.0.0</version> 
     </Acme_Newcoolmodule> 
    </modules> 
    <frontend> 
     <layout> 
      <updates> 
       <newcoolmodule> 
        <file>newcoolmodule.xml</file> 
       </newcoolmodule> 
      </updates> 
     </layout> 
    </frontend> 
</config> 

,其中Acme的- 命名空間Newcoolmodule - 模塊名稱上的Magento駝峯使用

簡介:

您的config.xml文件中保存您的前綴一個配置節點稱爲global/models/yourpackage爲您的班級模型。

當您撥打Mage::getModel('packagename/classname')時,Magento會取回此配置節點。 Company_Yourmodule_Models增加了_,然後用首字母大寫的類名:

Company_Yourmodule_Models_Classname

如果你有cAMElcaSe類名,這也是同樣的道理。所以,假設你的班級的名字是ClassName,那麼你必須致電Mage::getModel('packagename/className'),並且magento將其解析爲:Company_Yourmodule_Models_ClassName

+0

嗯,是駱駝案件的問題? – Dencker

+0

@Dencker看到我編輯的答案。粘貼上面的配置代碼,並檢查 – Slimshadddyyy

+0

現在嘗試一切,假設Acme_Newcoolmodule也在第一個代碼塊中。仍然不起作用。我正在製作一臺生產服務器(是的,我知道,我是一個壞男孩),所以也許其他一些模塊會覆蓋標題。在Magento Markup中重要的CSS可以做到嗎? – Dencker