Part of the EllisLab Network
   
 
CI Hack, Recess framework like dynamic routing
Posted: 22 December 2008 07:11 PM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  2
Joined  08-27-2006

Saw this
http://www.recessframework.org/blog

thought it looked cool, so I wrote up a quick hack to implement the basic idea

http://istillseeglaciers.com/MY_Router.phps

Issues:
  Fantastically horrible hack to implement this, I ended up changing a couple lines in CodeIgniter.php despite my best efforts.  I think I could fix this if I used a subprocess to build the routes, but I haven’t done that yet.

Todo:
  Add in caching to store routes cleaned from the controllers.
  Unhaxor the CI

Add in dynamic context/behavior rules:
  ex: `@isAjax` to tell the router that if a call to a method doesn’t present itself as an ajax call then abort it.

Why:
  Because its cool and I kind of liked the idea of embedding routes inside of my controllers instead of in a centralized config file.

 Signature 

Beware of “experimental code”, the minute you put your guard down and think it’s safe… thats when it pilfers your wallet, knocks your daughter up, and humiliates you infront of a critical audience. -DjW

Profile
 
 
Posted: 23 December 2008 04:27 AM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4785
Joined  07-14-2006

I’ve seen it too and i liked it a lot.

The way i would add it is to write a hook function for it and add it to the presystem hook. The function generates the $route[‘regex’] = ‘ci url’; lines for the routes.php file.

While developing you can leave the hook in, which will render the pages slower, but you will have instant routes. For production you remove the hook.

But i also was thinking about another way of adding the routes

function fantastic() /* custom/route */ 

This way you can regex the lines instead of using all kinds of other parse functions.

Maybe this gives you so ideas.

Profile