[wp-trac] [WordPress Trac] #12935: Evolve the URL routing system
WordPress Trac
wp-trac at lists.automattic.com
Thu May 27 23:07:46 UTC 2010
#12935: Evolve the URL routing system
--------------------------+-------------------------------------------------
Reporter: mikeschinkel | Owner: ryan
Type: enhancement | Status: new
Priority: normal | Milestone: 3.1
Component: Permalinks | Version: 3.0
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
Comment(by mikeschinkel):
Replying to [comment:31 jacobsantos]:
> Replying to [comment:28 mikeschinkel]:
> > I am aware of your advocacy of an MVC approach similar to Django and
what I assume CakePHP, CodeIgnitor and Rails use but I think that would so
significantly change that it is not viable, at least not in one
revolutionary step. The approach I'm taking it is maintain the concept
for mapping URLs to query vars and letting query vars drive the loading of
content.
>
> Not really, the systems like that take a directory controller approach,
where you have a single class within a directory. I don't believe
WordPress would ever adopt that system, nor do I fully believe that is the
best way to do it. Easier yes, but applicable to every system? Probably
not.
>
> What I envision for WordPress is more like Zend Framework and what I
kind of assumed you were going to implement. Really, I mean the Routes and
URI segment code is similar enough that most libraries probably duplicate
a lot of the same code. Where the differences are in the way the
controller is loaded and executed.
Sounds like you are more familiar with the specifics of those systems than
me. I admittedly don't know anything about how Zend goes about it's
routing though I'm sure it would be useful for me to study it just so I'll
know. I'll add to my (ever growing) reading list. :)
>
> I'm thinking it might look similar to:
>
> {{{
> <?php
> wp_register_controller($route, $callback);
> ?>
> }}}
>
> This might look up the route and add the callback or register the route
with the callback.
While I'm not familiar with the structures of `$route` and `callback` I
presume they are similar in concept to what we are discussing.
It would seem with the structure I'm working on it should be possible to
extend to something like this:
{{{
register_route_segment('%baz%',array(
'parent_path' => array('%foo%','%bar%'),
'optional' => true,
'callback' => 'baz_with_the_foo_and_the_bar(),
));
}}}
While I don't think it would be a good idea to pursue this direction for
v3.1 I do think we should ensure it is absolutely possible for you to
extend it in that manner via hooks or other extensibility options.
> I do think we are looking at two different problems. My problem is that
I know the controller implementation is difficult and needs a lot of work.
Your problem is that the routes themselves need a better implementation.
Our goals are not conflicting. My goals can be accomplished on top of your
implementation and I believe I will most likely focus on supporting both
the current system and yours when you develop it.
> > I think many implementations piggy back onto the Routes implementation
for loading the controller. That doesn't need to be the case in this. They
could be kept separate and made to just basically the controller checks
the route and then loads the correct callback. This could be done now, it
is just easier when the routes is created for that specific purpose
instead of the way it is now with WordPress routes the main focus and
extra routes something that is just tacked on as supported, but not quite
fully.
Yes, I would agree with that, and glad to hear that you think my work
could be something you could build on rather than bypass.
> > '''One point of note'''; the innovation over this approach compared to
the existing rewrite system is that '''it inspects path segments instead
of full paths'''.
>
> This will work much like the others, which will lead it towards a
controller implementation that makes sense to those who work with the
others.
Awesome!
Glad I'm going in the right direction for a change! (that's a general
comment, not aimed at anyone in particular. :)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12935#comment:34>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list