Question

I have a controller file with the two actions i.e :

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }

    public function doLoginAction()
    {
        // action body
    }
}

and their corresponding view files. i.e when i hit http://www.mydomain.com/index it loads the index view. The problem I am facing is that when I try to access the index action of this controller it will load the corresponding view but when I try to hit the dologin action it gives the error

http://www.mydomain.com/index/dologin

*Message: Action "dologin" does not exist and was not trapped in __call()*

Request Parameters:

array (
  'controller' => 'index',
  'action' => 'dologin',
  'module' => 'default',
)  

same is happening when I try it with another controller and action. The index action runs fine for that controller too but not any other action in the controller.

P.S : I have configured mod_rewrite module and AllowOverride ALL in apache config file

Was it helpful?

Solution

Camel-cased action names are expected to be dashed as params. Therefore, doLoginAction() will respond to /default/index/do-login, not dologin. If you wish the URL to be dologin, you should rename the action to dologinAction().

OTHER TIPS

You can have hyphen(-) separated urls at controller level also.

Suppose you need a url like this:

http://www.mydomain.com/do-some-stuff/my-stuff/

Then your controller should be named as:

DoSomeStuffController (as class name) && DoSomeStuffController.php (as controller file name)

and

myStuffAction() (as your method name)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top