开发者

Magento - how to declare multiple helper classes in the same config

Could someone please tell me how I can declare multiple helpers within the same config file for the same module?

I've been using helper utility files for awhile now, but as my utility method is becoming increasingly long, with many functions, I'd like to split i开发者_如何学编程t up into seperate helper utility classes based on the functionality. So I'd have a class called Categoryhelper and one called Attributehelper. Obviously this step I can do, but I'm not sure how to declare these in the config.xml.

I've tried messing around with the config, doing trial and error but cant seem to get anything to work.

Here's what I originally had, using the default helper:

(note - my custom module name is called 'Helper'

<global>
...
<helpers>
    <helper>
        <class>GPMClient_Helper_Helper</class>
        </helper>
</helpers>
...

and here's what I've tried:

<helpers>
<helper>
            <class>GPMClient_Helper_Helper/Categoryhelper</class>
    </helper>
    <helper>
            <class>GPMClient_Helper_Helper/Attributehelper</class>
    </helper>

and:

<helpers>
<helper>
            <class>GPMClient_Helper_Helper/Categoryhelper</class>
        <class>GPMClient_Helper_Helper/Attributehelper</class>
    </helper>

Should the helper classes go into their own xml fragment or should both be grouped together?

If anyone could please post a sample config with multiple helper classes declared, I'd be most grateful.

Thanks, Ian


Seems like you got wrong how it works. When you add next lines to your GPMClient_Helper module config.xml

<helpers>
    <helper>
        <class>GPMClient_Helper_Helper</class>
    </helper>
</helpers>

you define class prefix for all your helpers. So, now in your GPMClient/Helper/Helper directory you should create file Data.php with GPMClient_Helper_Helper_Datacode inside and any number of classes named GPMClient_Helper_Helper_*.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜