EllisLab text mark
Advanced Search
     
How routers.php exactly works on HMVC by wiredesignz?
Posted: 18 February 2011 07:40 AM   [ Ignore ]
Avatar
Joined: 2007-12-18
174 posts

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:

$route['default_controller'"historic"

And my application routes.php:

$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!

 
Posted: 18 February 2011 08:01 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

There can only be one default controller!

$route['projects/(:any)'"projects/historic/$1"

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

InsiteFX

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 18 February 2011 08:19 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-18
174 posts

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!

 
Posted: 18 February 2011 09:59 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-11
2985 posts

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.

 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

 
Posted: 18 February 2011 10:31 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-08
14 posts

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:

$route['foo''bar/method'
 Signature 

http://stegelman.com

 
Posted: 21 February 2011 05:41 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-18
174 posts

Thank you two guys!

 
Posted: 21 February 2011 09:46 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-18
174 posts

Another question about the same:

Why this route:

$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!

 
Posted: 02 March 2011 09:54 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2011-01-30
6 posts
Isern Palaus - 21 February 2011 02:46 PM

Another question about the same:

Why this route:

$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!

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

In application/config/routes.php I have:

$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!