Some of you might have seen my router plugin "Molajo Router", which is a
proof of concept of an improved routing system in Joomla. You can
download the plugin from here: http://www.joomlager.de/molajorouter.zip
(The plugin currently is not fully functional and the title is just a
working title)
I'd like to introduce this feature into Joomla and have started with a
pull request for a revised JRouter class:
https://github.com/joomla/joomla-platform/pull/354
As is described in the pull request, the changes to the framework are
actually not that big, the changes to the CMS are a lot bigger.
The benefits:
1. Routing is a tiny bit faster
2. The routing is more flexible and does not impose some pre-defined
rules that can not be switched off.
3. Writing a component router is now object oriented and if we want to
implement the full feature set of the plugin, its also just one line of
code per view and you are done.
4. Helper classes like ContentHelperRoute are not necessary anymore and
the related bugs are automatically fixed.
5. URLs are always the same, regardless of them being sent through
ContentHelperRoute or just through JRouter.
6. You can hand over a URL string or an associative array of URL
parameters to JRoute
7. URLs can be changed simply by switching the rules by which they are
build without touching the component router
The downsides:
1. Most of the SEF extensions that touch URLs wont really work anymore
(most likely)
However, the system is backwards compatible for all components and their
router.
I'd like to get this into 2.5 and would like to get approval for this
and instructions how to proceed.
Hannes
--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To post to this group, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-cm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
Hannes
> <mailto:joomla-...@googlegroups.com>.
> To unsubscribe from this group, send email to
> joomla-dev-cm...@googlegroups.com
> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com>.
Besides that, I regard the hard coded rules how the URLs are treated as
a bug and the big issues in writing your own component router as bugs.
Writing a component router is still regarded as being black magic and
very few people understand the system and how to use and code for it
properly, resulting in either no router at all or very simple routers
that don't create the result that we are looking for.
Hannes
Am 21.09.2011 20:43, schrieb brian teeman:
> Can you outline the " issues with the routing" that this addresses and
> how it does it. --
> You received this message because you are subscribed to the Google
> Groups "Joomla! CMS Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-cms/-/euiedlLnkRcJ.
The system that I developed in the plugin is based on the idea that
every change to the URL is a rule and rules are actually nothing more
than function callbacks. So for the default Joomla behavior, there is a
plugin that, when enabled, registers a bunch of functions in a special
order, which do all the processing. If you want to change the behavior,
you write your own plugin and add your own rule (=function callback) to
the router. In the extreme case, you could deactivate the Joomla plugin
and replace all the rules with your own without any changes to the core
files, without any overrides and without any compatibility issues. With
a little bit of standardization, we could even change the URLs to a date
based scheme, which I normally refer to as Wordpress Style URLs. You can
see an example how that would be done with this plugin:
http://www.joomlager.de/molajowp.zip Another possibility is the stub for
a REST interface, which you can see here:
http://www.joomlager.de/molajorest.zip
If you mean the easy to write component routers:
First of all: We only need routes to views. Every other task than
"display" should do its thing and then redirect us to the display task
again. So that reduces the number of combinations that we have. Then we
have a hierarchy on the different views. A categories view is the parent
of a category view and a category view is the parent of an article view.
The idea of my component router now is that you only have to register
the dependencies between different views and the ID variables that are
used based on the view that you use. The specific details that we have
to register are:
1. unique name for the view in the component
2. name of the view (for example "article")
3. name of the ID variable if present (for example "id")
4. name of the parent view if present (for example "category")
5. name of the parent views ID variable if present (for example "catid")
6. is the view nestable (can I navigate from this view to the same view
again? for example from a parent category to a child category)
7. if I'm navigating to this view (with this specific name (you can use
the same view more than once in the path of your child and parent
views)) I should be using this layout
Everything except #1 and #2 are optional and in the last 8 months I
haven't come across a structure that could not be mapped by this.
Now, the component router is made a class in this new system and in the
constructor this data is registered. (If you want to add more views by a
plugin or something, that is possible, too) The class extends a
JComponentRouter class (not yet part of the pull request to the platform
project) which again can register rules (=function callbacks) to be used
on a component level and which can then build and parse the URLs based
on the information given above. With all this in place, the complete
router for com_content could look like this:
jimport('joomla.application.component.router');
class ContentRouter extends JComponentRouter
{
function __construct()
{
$this->register('categories', 'categories');
$this->register('category', 'category', 'id', 'categories', '',
true);
$this->register('article', 'article', 'id', 'category', 'catid');
$this->register('archive', 'archive');
$this->register('featured', 'featured');
parent::__construct();
}
}
In a second step, we could add functions to retrieve a little bit more
information (the article alias) to remove the IDs from the URLs.
Hope that explains it.
Hannes
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! CMS Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-cms/-/jvRntpgpnIUJ.
I don't quite understand this one, the routers create an array of
strings which get appended together to create the url, or in reverse
take an array of strings and reverses them.
While all the routers that come with components are simplistic, it's not
that difficult to customize a router to use specific rules for different
sections of content[I've done that quite frequently where sobi or
adsmanager needed different url structures depending on the category of
the item].
It's not really that difficult to go from that to having a customizable
router for a component where you can set different rules.
If instead of just using a set of rules, you added in the ability to set
the rule "traditional joomla routing" - and if that is chosen run the
traditional routing mechanism functions, then your backwards compatible
along with new features.
In any case, 2.5 is already going to include a new search function which
may not be backward compatible, I see no reason not to improve the
router since the router is just about universally not used in favor of
installing very complicated alternatives. The current router works
great for coders who can create custom routers for every component they
use, but it's not so good for end users.
Make the router "joomla"...ie, add events to it.
routerBeforeSEF
routerAfterSEF
routerBeforeDecode
routerAfterDecode
run before and after converting a url to SEF, and run before and after
Decoding. Before decoding or SEF give it a chance to change the order
of the rules, disable rules, enable rules. After give it a chance to
modify the result.
In addition to that, on the CMS side add a router component to give
access to the overall rules settings, and to modify the rules for a
specific component. I'd also add a few events there:
routerGetRules
routerConfigureRule
So any component can include a plugin which adds additional rules[either
universal rules or rules limited to a specific component] and the router
component can use the GetRules event to find all those rules and display
them for configuration. A rule should likely be contained in an array
including the component(s), the rule name, and configuration
parameters. Either those parameters need to be stored by the router
component itself...or sent to the component plugin via
routerConfigureRule event and allow the component to store that data.
Hannes
Hannes
Its completely installable and works. (I've seen a tiny bug with the
URLs, but otherwise...) For now, the language files and comments in the
code are missing, but the rest should already be fine.
I would be happy if people could take a look at this and maybe test it
with one of their own components. I would also be very happy if the PLT
could (re-)consider this change for 2.5. Thank you
Hannes
Am 21.09.2011 19:09, schrieb Mark Dexter:
> <mailto:joomla-...@googlegroups.com>.
> To unsubscribe from this group, send email to
> joomla-dev-cm...@googlegroups.com
> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com>.
Can this be implemented in 2.5 as a checkbox in Global Configuration
similar, next to the core SEF settings?
By default 'legacy mode' is 'on' the old router code is active and all SEF
extensions still work and backwards
compatibility is maintained, but a User can flip it on as extensions become
'2.5 native'.
In 3.0 the checkbox goes away with the legacy router.
Just a thought.
Hannes
Routers are one of the very last bastions of black magic left and I
would consider it a major improvement to the CMS as a whole.
- Rune
One big improvement was the removal of the legacy mode in the actual
router and instead providing a default router that handles the legacy
mode if necessary. That means that all component routers now use the
class method, but in case that the component uses legacy routers (=the
functions instead of a class) a router "JDefaultRouter" is registered,
which either calls the legacy routers or provides a router (that does
nothing) for extensions that don't have a router. We also implemented an
interface that every new router class has to implement in order to be
recognized as a new router to prevent legacy issues. (Specifically
Kunena already had a class named KunenaRouter, which would collide with
this implementation)
The general gain by this new router seems to be about 50% on my system,
Matias had even extremely larger gains of 400% and more. Since our
measuring methods differ a bit and since the actual performance also
depends on the use cases, you can't really compare the results, but the
tendency is clear that the code is quite a lot faster.
Now, what do we have to do to get this (or parts of it) into 2.5?
Hannes
You can find the branch here:
https://github.com/Hackwar/joomla-cms/tree/jrouter-temp
I would be happy if the PLT could accept this proposal and as soon as I
have the issues of the component routers worked out, I would be even
happier if you would accept those changes, too. I'm working hard to make
this possible for Joomla 2.5.
Hannes
> >>> <hack...@googlemail.com <mailto:hack...@googlemail.com>>
> >>> To: <joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>>
> <mailto:hack...@googlemail.com
> >>>>> <mailto:joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>>.
> >>>>> To unsubscribe from this group, send email to
> >>>>> joomla-dev-cm...@googlegroups.com
> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com>
> >>>>> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com
> <mailto:joomla-dev-cms%252Buns...@googlegroups.com>>.
Here is the branch with the latest work, where I'm fixing the component
routers: https://github.com/Hackwar/joomla-cms/tree/jrouter-temp
Please test and comment.
Hannes
> > Am 04.10.2011 12:56, schrieb Rune V. Sj�en:
> > > I had a play with this new routing functionality not too long
> > ago and
> > > I have to say, it is the only router implementation i've
> ever looked
> > > at (in my test component) without wanting to jump off a
> bridge.
> > If it
> > > really is fully backwards-compatible I would very much like to
> > see it
> > > in 2.5 as we do indeed have at least 3 months of time to
> test it.
> > >
> > > Routers are one of the very last bastions of black magic
> left and I
> > > would consider it a major improvement to the CMS as a whole.
> > >
> > > - Rune
> > >
> > > On Tue, Oct 4, 2011 at 8:37 AM, Hannes Papenberg
> > > <hack...@googlemail.com
> <mailto:hack...@googlemail.com> <mailto:hack...@googlemail.com
> <mailto:hack...@googlemail.com>>>
> > >>> To: <joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>
> > <mailto:joomla-...@googlegroups.com
> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com
> <mailto:joomla-dev-cms%252Buns...@googlegroups.com>
> > <mailto:joomla-dev-cms%252Buns...@googlegroups.com
> <mailto:joomla-dev-cms%25252Bun...@googlegroups.com>>>.
I'd love to deliver the full package including the component routers,
but since time is of the essence, I'd like to propose this reduced
version of the router-rewrite. Maybe I find the time to get the
component routers fixed, too, but it would be a shame if this change
could not be implemented now because of this delay.
You can find the branch here:
http://joomlacode.org/gf/project/joomla/scmsvn/?action=browse&path=%2Fdevelopment%2Fbranches%2Fhannes%2F
And the Feature Tracker Item here:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=26942
The code in the branch is final, can be tested and merged into trunk. If
the CMS approves of these changes, Andrew said he would look favourably
onto adopting this code for the platform. In that case I will create a
new pull request. So please test and hopefully approve. :-)
Hannes
> > Am 04.10.2011 12:56, schrieb Rune V. Sj�en:
> > > I had a play with this new routing functionality not too long
> > ago and
> > > I have to say, it is the only router implementation i've
> ever looked
> > > at (in my test component) without wanting to jump off a
> bridge.
> > If it
> > > really is fully backwards-compatible I would very much like to
> > see it
> > > in 2.5 as we do indeed have at least 3 months of time to
> test it.
> > >
> > > Routers are one of the very last bastions of black magic
> left and I
> > > would consider it a major improvement to the CMS as a whole.
> > >
> > > - Rune
> > >
> > > On Tue, Oct 4, 2011 at 8:37 AM, Hannes Papenberg
> > > <hack...@googlemail.com
> <mailto:hack...@googlemail.com> <mailto:hack...@googlemail.com
> <mailto:hack...@googlemail.com>>>
> > >>> To: <joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>
> > <mailto:joomla-...@googlegroups.com
> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com
> <mailto:joomla-dev-cms%252Buns...@googlegroups.com>
> > <mailto:joomla-dev-cms%252Buns...@googlegroups.com
> <mailto:joomla-dev-cms%25252Bun...@googlegroups.com>>>.
Hannes
JM
>What happened to this proposal did it get into J 2.5 (or why not) ?
>
>--
>You received this message because you are subscribed to the Google
>Groups "Joomla! CMS Development" group.
>To post to this group, send an email to joomla-...@googlegroups.com.
>To unsubscribe from this group, send email to
>joomla-dev-cm...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
--
>Please keep the Subject wording in your answers
This e-mail and any attachments may be confidential. You must not
disclose or use the information contained in this e-mail if you are
not the
intended recipient. If you have received this e-mail in error, please
notify us immediately and delete the e-mail and all copies.
-----------------------------------------------------------
Jean-Marie Simonet / infograf768
Joomla Production Working group
Joomla! Translation Coordination Team
- Rune
On Tue, Feb 21, 2012 at 9:18 AM, JM Simonet <infog...@gmail.com> wrote:
> Read above Mark's reply.
>
> JM
>
>
>> What happened to this proposal did it get into J 2.5 (or why not) ?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Joomla! CMS Development" group.
>> To post to this group, send an email to joomla-...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> joomla-dev-cm...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
>
>
>
> --
>>
>> Please keep the Subject wording in your answers
>
> This e-mail and any attachments may be confidential. You must not disclose
> or use the information contained in this e-mail if you are not the
> intended recipient. If you have received this e-mail in error, please notify
> us immediately and delete the e-mail and all copies.
> -----------------------------------------------------------
> Jean-Marie Simonet / infograf768
> Joomla Production Working group
> Joomla! Translation Coordination Team
I've yesterday cleaned up the router implementation and am starting to write the tests as requested by elin. You can help me write those, if you want. I first need to find a structure to add this to the unittests in a way that keeps the platform and cms parts apart.
Hannes
Here is the branch with the router work:
https://github.com/Hackwar/joomla-cms/tree/jrouter
I think, I'm going to request that at least the non-component router
part is accepted, which already would solve so unbelievably much. Right
at this moment, I don't see a way to fulfill the required tests, since
there are no usable unittests in the CMS. So please advise how to proceed.
Hannes
Am 21.02.2012 13:07, schrieb Hannes Papenberg:
>
> I've yesterday cleaned up the router implementation and am starting to
> write the tests as requested by elin. You can help me write those, if
> you want. I first need to find a structure to add this to the
> unittests in a way that keeps the platform and cms parts apart.
>
> Hannes
>
> Am 21.02.2012 11:50 schrieb "Rune V. Sj�en" <rvs...@gmail.com
> <mailto:rvs...@gmail.com>>:
>
> To sum it all up, now that the 2.5 LTS is out the door, the window for
> new features in 3.0 STS is imminent. As this will greatly decrease my
> desire to hurt myself while writing routers, what do we need to do in
> order to make this happen?
>
> - Rune
>
> On Tue, Feb 21, 2012 at 9:18 AM, JM Simonet <infog...@gmail.com
> <mailto:infog...@gmail.com>> wrote:
> > Read above Mark's reply.
> >
> > JM
> >
> >
> >> What happened to this proposal did it get into J 2.5 (or why not) ?
> >>
> >> --
> >> You received this message because you are subscribed to the
> Google Groups
> >> "Joomla! CMS Development" group.
> >> To post to this group, send an email to
> joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>.
> >> To unsubscribe from this group, send email to
> >> joomla-dev-cm...@googlegroups.com
> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com>.
> >> For more options, visit this group at
> >> http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
> >
> >
> >
> > --
> >>
> >> Please keep the Subject wording in your answers
> >
> > This e-mail and any attachments may be confidential. You must
> not disclose
> > or use the information contained in this e-mail if you are not the
> > intended recipient. If you have received this e-mail in error,
> please notify
> > us immediately and delete the e-mail and all copies.
> > -----------------------------------------------------------
> > Jean-Marie Simonet / infograf768
> > Joomla Production Working group
> > Joomla! Translation Coordination Team
> > --
> > You received this message because you are subscribed to the
> Google Groups
> > "Joomla! CMS Development" group.
> > To post to this group, send an email to
> joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>.
> > To unsubscribe from this group, send email to
> > joomla-dev-cm...@googlegroups.com
> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com>.
> > For more options, visit this group at
> > http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! CMS Development" group.
> To post to this group, send an email to
> joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>.
> To unsubscribe from this group, send email to
> joomla-dev-cm...@googlegroups.com
> <mailto:joomla-dev-cms%2Bunsu...@googlegroups.com>.