A route forever the same controller plus several functions

Asked

Viewed 114 times

1

I have the following link meusite.com/admin/concursos/concursos. My folders inside the controllers are like this:

-admin
  +atos
  -concursos
    ->concursos.php
  +licitacoes

This link takes the function index of controller, admin and the administrative panel folder, concursos and the folder for the controller, and the last concursos of the link and the controller concursos.php.

If I create the route $route['admin/concursos/'] = 'admin/concursos/concursos'; he takes me through the link meusite.com/admin/concursos normal until the index, more precise that this same route always take me to other functions without having to keep creating a route to a new function as for example: meusite.com/admin/concursos/visualizar/1, meusite.com/admin/concursos/editar/1.

There is the possibility of a route responding to all these links?

  • 1

    You could go into more detail?

  • @Renatosilva I made a small edition. More I believe I explained well, sometimes and complicated understand why you are not well iterated in the situation.

  • @Renatosilva More so that always I do not need to add a new route every time I access a different function. Because if I set this course $route['admin/concursos/'] = 'admin/concursos/concursos' it will only access the index function of this controller, more precise that this route always meets other functions like admin/concursos/visualizar/5.

  • @Renatosilva I’m in Codeigniter 3.

1 answer

2

I decided as follows:

$route['admin/concursos'] = 'admin/concursos/concursos';
$route['admin/concursos/(.*)'] = 'admin/concursos/concursos/$1';

The first route indicates that whenever you use url admin\concursos will take me to the index of controller, the second route indicates that I can specify the function I will call inside the controller.

I can also do it only as follows:

$route['admin/concursos/(.*)'] = 'admin/concursos/concursos/$1';

But there I need to inform index in url admin\concursos\index

Browser other questions tagged

You are not signed in. Login or sign up in order to post.