Neden Magento ziyade benim özel ad daha Mage ad aramak için çalışıyor?

1 Cevap php

I’ve created a module within the local code folder in our custom namespace. The block isn’t displaying on the frontend, and on checking the exception log, it turns out Magento is looking in the wrong place.

exception ‘Mage_Core_Exception’ with message ‘Invalid block type:
Mage_MyCompany_ForthcomingProducts_Block_List’
in /var/www/html/app/Mage.php:407

The same also goes if I exclude the MyCompany_ prefix when calling the block; it still looks in the Mage namespace. I have this in a file called MyCompany_All.xml in the modules folder, and the CMS layouts I’ve added are working fine, so Magento is definitely loading it:

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

Does anyone have any ideas as to what’s causing this?


Added: The block is being called by a static block with this template code:

{{block type="MyCompany_ForthcomingProducts/List" template="forthcomingproducts/list.phtml"}}

Ve blok için config.xml olduğu:

<?xml version="1.0" encoding="utf-8"?>
    <config>
        <modules>
            <MyCompany_ForthcomingProducts>
                <version>0.9</version>
            </MyCompany_ForthcomingProducts>
        </modules>

        <global>
            <blocks>
                <forthcomingproducts>
                    <class>MyCompany_ForthcomingProducts_Block</class>
                </forthcomingproducts>
            </blocks>
       </global>
    </config>

1 Cevap

Aşağıdaki gibi blok beyanı ayarlamayı deneyin:

{{block type="forthcomingproducts/list" template="forthcomingproducts/list.phtml"}}

Config dosyada (forthcomingproducts) ve bloklar için bir takma ad tanımlanmış ve şimdi bunu takip etmelidir. Magento KQUEUE forthcomingproducts istediğiniz gibi MyCompany_ForthcomingProducts_Block, ardından classname MyCompany_ForthcomingProducts_Block_List yaratarak, büyük harfle sınıf adını (list) append olmak olacak. Eğer Magento (sizin örnekte MyCompany_ForthcomingProducts) hakkında bilmediği bir alis kullandığınızda, Mage ad parçası olarak kabul edilir.

Hope that helps, Joe