A little help understanding the controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: A little help understanding the controller (/showthread.php?tid=18171) Pages:
1
2
|
A little help understanding the controller - El Forum - 04-28-2009 [eluser]wiredesignz[/eluser] I use _remap() extensively with a base controller, _remap() is there for good reason and it is a very flexible feature of CI. Routes and (xwero's favourite) Hooks are ok, but _remap() in a base controller can give you much finer control over your application. EDIT: Try this base controller template to begin with, set up for a Blog application, but can be modified easily. Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); A little help understanding the controller - El Forum - 04-28-2009 [eluser]TheFuzzy0ne[/eluser] I don't run and hide. It's more of a light jog which leaves me slightly camouflaged. A little help understanding the controller - El Forum - 04-28-2009 [eluser]Dam1an[/eluser] [quote author="TheFuzzy0ne" date="1240945143"]I don't run and hide. It's more of a light jog which leaves me slightly camouflaged.[/quote] I was expecting you to say you LOLLERSKATE away A little help understanding the controller - El Forum - 04-28-2009 [eluser]TheFuzzy0ne[/eluser] I save the lollerskates for times when I need to move extremely fast. A little help understanding the controller - El Forum - 04-28-2009 [eluser]xwero[/eluser] wiredesignz MY_Controller is another thing that runs every time if you need it or not so all the bells in my head are ringing at the moment. But i understand you want to contain the module data. _remap can do its work if there are no better options. Colin changing the input class is the last thing i would think of to create userfriendly routes. A little help understanding the controller - El Forum - 04-28-2009 [eluser]intoitdaily[/eluser] wow thanks to everyone for the great support! It's obvious that this is quite a scalable framework and that there are many options. But I think I'm going to go with bargainph's suggestion and use routing. Afterall, it is exactly what I was looking for. When I get things running the way I want them, I'll repost my code and see if anyone else has some suggestions. Thanks again everybody! A little help understanding the controller - El Forum - 04-28-2009 [eluser]intoitdaily[/eluser] Holy Hell that was easy! It literally took me like 3 minutes to make it work! all I did was add Code: $route['blog/:num'] = 'blog/id'; In my controllers I changed all the Code: $this->uri->segment(3) Code: $this->uri->segment(2) Code: <?=anchor('blog/id/'. $row->id .'/', $row->title); ?> Code: <?=anchor('blog/'. $row->id .'/', $row->title); ?> so simple! The only thing is in a large application, you have to stay on top of your routes if this is something you do often. It can get a little bit confusing if you forget to change a redirect link or something in a view or controller. Thanks again guys! A little help understanding the controller - El Forum - 04-28-2009 [eluser]Dam1an[/eluser] Well done for getting it sorted out [quote author="intoitdaily" date="1240951826"] The only thing is in a large application, you have to stay on top of your routes if this is something you do often. It can get a little bit confusing if you forget to change a redirect link or something in a view or controller.[/quote] I normally seperate my routes into chunks, so all routes for posts go together, then all routes for users go together etc, it adds a bit of order... It starts to get really messy when you play witht he ordering to give certain routes precedence over others |