Welcome Guest, Not a member yet? Register   Sign In
How routers.php exactly works on HMVC by wiredesignz?
#1

[eluser]Isern Palaus[/eluser]
Hello,

I don't understand how the routes.php works in the HMVC structure.

I have:

/modules/projects
/modules/projects/config/routes.php
/modules/projects/controllers/historic.php

And the application structure:
/config/routes.php

My modules routes.php is:
Code:
$route['default_controller'] = "historic";

And my application routes.php:
Code:
$route['default_controller'] = "projects";

And I can't get it working. There is no other controller called projects con app/controllers/.

Thank you in advance!
#2

[eluser]InsiteFX[/eluser]
There can only be one default controller!

Code:
$route['projects/(:any)'] = "projects/historic/$1";

Not sure for your setup, but it is something like that.

InsiteFX
#3

[eluser]Isern Palaus[/eluser]
Hello insiteFX,

Thank you. What I want is that by default my module active is projects and inside projects I can defined what would be the default controller. As you can see english isn't my main language and I can't express exactly what I'm looking for.

Say I'm using projects/(:any), this would be a problem if I've another controller inside /modules/projects/controllers/ because it will route all to historic controller. I usually don't need to do routes, with /module-name/controller-name/action-name I've all I want but I want to define what would be the default module / controller active.

Thank you!
#4

[eluser]Phil Sturgeon[/eluser]
You don't need to set a default controller for a module as this is done already. A controller of the same name as the module will be called if no other name is provided.

http://example.com/projects will map to application/modules/projects/controllers/projects.
#5

[eluser]dstegelman[/eluser]
Add a route for the name of the module inside your modules routes.php to point to the controller you want to use. So if I have a module foo, and I want to call the controller bar/method then my /modules/config/routes.php would use this:
Code:
$route['foo'] = 'bar/method';
#6

[eluser]Isern Palaus[/eluser]
Thank you two guys!
#7

[eluser]Isern Palaus[/eluser]
Another question about the same:

Why this route:
Code:
$route["projects/historics/p/(:num)"]       = "projects/historics/index";

works in APP/config/routes.php and NOT in /APP/modules/projects/config/routes.php ?

How I've to set it to get it working?

Thank you!
#8

[eluser]libeco[/eluser]
[quote author="Isern Palaus" date="1298313989"]Another question about the same:

Why this route:
Code:
$route["projects/historics/p/(:num)"]       = "projects/historics/index";

works in APP/config/routes.php and NOT in /APP/modules/projects/config/routes.php ?

How I've to set it to get it working?

Thank you![/quote]

I am having the same problem when using Modular Extensions - HMVC (latest version currently, 2011-02-15).

In application/config/routes.php I have:
Code:
$route['nieuws'] = 'news/news/index';
This works.

When I remove that line and place it in application/modules/news/config/routes.php, it just sends me to the default controller.

Can anybody assist in this problem? Thanks in advance!




Theme © iAndrew 2016 - Forum software by © MyBB