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

Problem with custom module controllers
 
Lonnytunes
Jr. Member
 
Total Posts:  9
Joined:  2009-03-02
France
 

Hi all !

I am trying to modify the sitemap of the catalog module (catalo/.../seo/...).
As i diden’t know that it is possible to overriding module’s classes, I began to create a new module in app/code/local.
The problem is that i don’t succeed to call my module : 404 error when I click on the sitemap link.

Here is the tree of files :

Freestyler
--- AdvancedSiteMap
------ Block
--------- Sitemap.php
------ controllers
--------- SitemapController.php
------ etc
--------- config.xml
------ Helper
--------- Map.php

Map.php :

<?php

    
class Freestyler_AdvancedSiteMap_Helper_Map extends Mage_Core_Helper_Abstract
    {
    
        
public function getSiteMapUrl()
        
{
            
return $this->_getUrl('advancedsitemap/sitemap/index');
        
}
        
    }

I created a template called sitemap.phtml in design/frontend/default/default/template/freestyler
I added to repertory design/frontend/default/default/layout the layout advancedsitemap.xml :

<layout version="0.1.0">

    <default>

        <
reference name="top.menu">
            <
block type="catalog/navigation" name="catalog.topnav" template="catalog/navigation/top.phtml"/>
        </
reference>
        <
reference name="footer_links">
            <
action method="addLink" translate="label title" module="catalog" ifconfig="catalog/seo/site_map"><label>Site Map</label><url helper="advancedsitemap/map/getSiteMapUrl" /><title>Site Map</title></action>
        </
reference>
        <
reference name="footer">
            <
block type="core/template" name="footer.permanent.callout" template="callouts/footer.phtml">
                <
action method="setImgSrc"><src>images/media/footer_callout.jpg</src></action>
                <
action method="setImgAlt" translate="alt" module="catalog"><alt>Achat sécurisé Livraison Collissimo suivi 24h ou 48h</alt></action>
            </
block>          
        </
reference>

    </default>

<!--
SiteMap
-->

    <
advancedsitemap_sitemap_index>
        <
remove name="right"/>
        <
remove name="left"/>

        <
reference name="root">
            <
action method="setTemplate"><template>page/1column.phtml</template></action>
        </
reference>
        <
reference name="content">
            <
block type="page/template_container" name="seo.sitemap.container" template="freestyler/advancedsitemap/container.phtml">
                <
action method="setTitle" translate="title" module="catalog"><title>Plan du site</title></action>
                <
block type="advancedsitemap/sitemap" name="seo.sitemap.sitemap" as="sitemap" after="pager_top" template="freestyler/advancedsitemap/sitemap.phtml">
                    <
action method="setItemsTitle" translate="title" module="catalog"><title>plan du site</title></action>
                </
block>
            </
block>
        </
reference>
    </
advancedsitemap_sitemap_index>

</
layout>

I modified the catalog.xml in order to the link for sitemap call my helper to get the url :

<reference name="footer_links">
            <
action method="addLink" translate="label title" module="catalog" ifconfig="catalog/seo/site_map"><label>Site Map</label><url helper="advancedsitemap/map/getSitemapUrl" /><title>Site Map</title></action>
        </
reference>

I think that the problem is the url return by the helper and/or the layout.
I don’t understand very well the relation between controllers and layout, maybe I made full of stupid things.

Thanks.

PS : Sorry for my bad English !

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

Have you read this useful wiki? http://www.magentocommerce.com/wiki/how_to_overload_a_controller
It might be what you want to do.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lonnytunes
Jr. Member
 
Total Posts:  9
Joined:  2009-03-02
France
 

I have read this wiki, however i didn’t want to overload a controller but create a new.
But it’s good now, I have resolved my problem, it was my config.xml which was wrong.
Thanks for your reply.

 
Magento Community Magento Community
Magento Community
Magento Community
 
babberoo
Jr. Member
 
Total Posts:  29
Joined:  2009-07-07
Cheltenham, England
 

Can you please tell us what you did?

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