Question

I have URL: http://localhost/dir-withdash/controller

And this is folder structure.

/fuel
..../app
......../classes
............/controller
................/dir-withdash
..................../controller.php
............/model
............/view

the controller file is in /fuel/app/classes/controller/dir-withdash/controller.php

The problem is..

How to named the controller class? and How to route to his controller?


This is my controller class which is not work.

class Controller_DirWithdash_Index extends \Controller 
{


    public function action_index() 
    {

    }// action_index


}

This is my route which is not work too.

'dir-withdash/(.*)' => 'DirWithdash/$1',
Was it helpful?

Solution

If the aim is to have a hyphen in the URL, I would suggest that you remove the hyphen in the folder:

/fuel/app/classes/controller/DirWithdash/Home.php

Update the routes file to the following, where home points to your controller, and index is your action:

'dir-withdash/(.*)' => 'DirWithdash/Home/index/$1',

And update your class to the following:

class Controller_DirWithdash_Home extends \Controller 
{

    public function action_index() 
    {

    }// action_index

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top