Magento Forum

   
IndexController not working properly
 
PaulE
Member
 
Avatar
Total Posts:  43
Joined:  2008-12-09
 

I have some kind of issue with my custom module. In my config.xml file I have the following data for the frontend:

<frontend>
        <
routers>
            <
auction>
                <use>
standard</use>
                <
args>
                    <
module>Gadgetsvoor_Auction</module>
                    <
frontName>veilingen</frontName>
                </
args>
            </
auction>
        </
routers>
        <
layout>
            <
updates>
                <
auction>
                    <
file>auction.xml</file>
                </
auction>
            </
updates>
        </
layout>
    </
frontend>

As you can see, the module is called “auction”. I translated “auction” to dutch, thats why the frontName is “veilingen”.
When I go to http://www.mystore.com/veilingen I see the right page, but when I go to http://www.mystore.com/veilingen/id/4 I’m getting an 404 error.

When I tried to add a “die()” to my Index controller the page didn’t get killed. So I changed my frontname back to “auction”, and re-loaded the cache. This time I’m getting a blank page. But as soon as I remove “die()” I’m getting an 404 error again.

I used the following tutorial for my module:
http://www.magentocommerce.com/wiki/custom_module_with_custom_database_table

In the module creator the IndexController looks like:

<?php
class <Namespace>_<Module>_IndexController extends Mage_Core_Controller_Front_Action
{
    
public function indexAction()
    
{
        
        
/*
         * Load an object by id 
         * Request looking like:
         * http://site.com/<module>?id=15 
         *  or
         * http://site.com/<module>/id/15     
         */
        /* 
        $<module>_id = $this->getRequest()->getParam('id');

          if($<module>_id != null && $<module>_id != '')    {
            $<module> = Mage::getModel('<module>/<module>')->load($<module>_id)->getData();
        } else {
            $<module> = null;
        }    
        */
        
         /*
         * If no param we load a the last created item
         */ 
        /*
        if($<module> == null) {
            $resource = Mage::getSingleton('core/resource');
            $read= $resource->getConnection('core_read');
            $<module>Table = $resource->getTableName('<module>');
            
            $select = $read->select()
               ->from($<module>Table,array('<module>_id','title','content','status'))
               ->where('status',1)
               ->order('created_time DESC') ;
               
            $<module> = $read->fetchRow($select);
        }
        Mage::register('<module>', $<module>);
        */

            
        
$this->loadLayout();     
        
$this->renderLayout();
    
}
}

Mine looks now like:

<?php

class Gadgetsvoor_Auction_IndexController extends Mage_Core_Controller_Front_Action
{
    
public function indexAction()
    
{
        $auction_id 
$this -> getRequest() -> getParam('id');

          if(
$auction_id != null && $auction_id != '')
        
{
            $auction 
Mage::getModel('auction/auction') -> load($auction_id) -> getData();
            die(
$auction);
        
}

        $this 
-> loadLayout();
        
$this -> renderLayout();
    
}
}

How can I set this up to work? Because when I go to http://www.mysite.com/auction?id=4 it all works fine…

Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
PaulE
Member
 
Avatar
Total Posts:  43
Joined:  2008-12-09
 

Somebody?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Manos Dilaverakis
Member
 
Total Posts:  49
Joined:  2009-02-25
 

While I haven’t got this entirely clear in my head I have the distinct impression that you’re missing a controller.

Read the answer to this question and specifically the end where he describes app/code/local/MyCompanyName/HelloWorld/controllers/FooController.php.

 
Magento Community Magento Community
Magento Community
Magento Community
 
PaulE
Member
 
Avatar
Total Posts:  43
Joined:  2008-12-09
 

Thanks, there was also an problem with my module config though wink But it’s working fine now! Had to create a new controller.

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