in my site i need process the following urls:
http://localhost/groups/{id_group}
localhost/groups/{id_group}/events
localhost/groups/{id_group}/events/{id_event}
localhost/groups/{id_group}/events/{id_event}/galery
localhost/groups/{id_group}/events/{id_event}/galery/{id_galery}/{id_photo}
localhost/groups/{id_group}/events/{id_event}/notes/{id_note}
I created the following structure:
application/
application/groups/
application/groups/controllers
application/groups/controllers/GroupController.php
application/groups/controllers/GroupEventsController.php
application/groups/controllers/GroupEventsGaleryController.php
application/groups/controllers/GroupEventsNotesCont开发者_开发知识库roller.php
Is this the right way to do it?. The main problem I have is that in each of these controllers i need access to data of the group and would be repeating code in all controllers. For example in the controller GroupEventsGaleryController and GroupEventsNotesController i need group's data and event. I dontknow how to do this well.
Please help. Thanks.
You'll need to pass the IDs via GET anyway, I presume. I'd do it this way:
modules
--group
--controllers
IndexController.php
EventController.php
GalleryController.php
NoteController.php
--views
--scripts
--index
index.phtml
...
--event
index.phtml
...
--gallery
index.phtml
...
--note
index.phtml
...
(this doesn't mean your structure isn't going to work, I just find this clearer).
Then you can write a custom router that will structure your URLs the way you propose.
精彩评论