Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom layout, custom module
 
tsifra
Member
 
Total Posts:  57
Joined:  2008-09-14
 

Hi! I’ve searched forum, but haven’t found anything helpfull. If this proble was discussed somewhere, give me link please.

I’m trying to create custom module with custom layout.

Enabling module
app/etc/modules/Mycompany_Bikerequest.xml

<?xml version="1.0"?>

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

Creating code
app/code/local/Mycompany/Bikerequest

../controllers/IndexController.php

class Mycompany_Bikerequest_IndexController extends Mage_Core_Controller_Front_Action
{
}

../Helper/Data.php

class Mycompany_Bikerequest_Helper_Data extends Mage_Core_Helper_Abstract
{
}

../etc/config.xml

<?xml version="1.0"?>

<config>
    <
modules>
        <
Mycompany_Bikerequest>
            <
version>0.1.0</version>
        </
Mycompany_Bikerequest>
    </
modules>
    <
frontend>
        <
routers>
            <
bikerequest>
                <use>
standard</use>
                <
args>
                    <
module>Mycompany_Bikerequest</module>
                    <
frontName>bikerequest</frontName>
                </
args>
            </
bikerequest>
        </
routers>
        <
layout>
            <
updates>
                <
bikerequest>
                    <
file>bikerequest.xml</file>
                </
bikerequest>
            </
updates>
        </
layout>
    </
frontend>
    <global>
        <
template>
            <
email>
                <
bikerequest_email_email_template module="bikerequest">
                    <
label>Bike request form</label>
                    <
file>bikerequest_form.html</file>
                    <
type>text</type>
                </
bikerequest_email_email_template>
            </
email>
        </
template>
    </global>
</
config>

Creating layout

<?xml version="1.0"?>

<layout version="0.1.0">
    <default>
        <
reference name="footer_links">
            <
action method="addLink" translate="label title" module="mycompany_bikerequest"><label>Bike request</label><url>bikerequest</url><title>Bike request</title><prepare>true</prepare></action>
        </
reference>
    </default>

    <
bikerequest_index_index>
        <
reference name="root">
            <
action method="setTemplate"><template>page/2columns-right.phtml</template></action>
            <
action method="setHeaderTitle" translate="title" module="mycompany_bikerequest"><title>Contact Us1</title></action>
        </
reference>
        <
reference name="content">
            <
block type="core/template" name="bikerequestForm" template="bikerequest/form.phtml"/>
        </
reference>
    </
bikerequest_index_index>
</
layout>

When i try http://www.mydomain.com/index.php/bikerequest i’ve got following error

Fatal error: Class 'Mage_Mycompany_Bikerequest_Helper_Data' not found in /home/webmaster/www/dev/app/code/core/Mage/Core/Model/App.php on line 785

Magento adds Mage_ prefix to my class name.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Syndia
Member
 
Total Posts:  38
Joined:  2008-04-01
Netherlands, The
 

Hi,

you have to define your Helper in the ../etc/config.xml like this,

...
<global>
...
        <
helpers>
            <
bikerequest>
                <class>
Mycompany_Bikerequest_Helper</class>
            </
bikerequest>
        </
helpers>
...
</global>
...
 
Magento Community Magento Community
Magento Community
Magento Community
 
tsifra
Member
 
Total Posts:  57
Joined:  2008-09-14
 

Pricol, thank you. But nothing happens.

System is steel looking for Mage_Mycompany_Bikerequest_Helper_Data

Seems like bug.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Syndia
Member
 
Total Posts:  38
Joined:  2008-04-01
Netherlands, The
 

You refreshed your cache or disabled it?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tsifra
Member
 
Total Posts:  57
Joined:  2008-09-14
 

Problem with layout fixed partially.

I should use bikerequest instead of mycompany_bikerequest.

There is no more errors, but this directive in layout does nothing.

<default>
        <
reference name="footer_links">
            <
action method="addLink" module="bikerequest"><label>Bike request</label><url>bikerequest</url><title>Bike request</title><prepare>true</prepare></action>
        </
reference>
    </default>

If i place this code into contacts.xml layout everything is fine. Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top