Let's use that just because it's the first topic that came up from the search.
Today I started playing with semantic urls.
The current progress is this one:
The general idea is:
- Url_Generator stores all the possible alternative "url generators",
- "Standard" is the normal one, no whistles, current ?topic=123 etc. and it will be the default fallback in case a "type" of URL is not known (I'm not entirely sure if this feature is actually needed, but it seemed fit into the design, so I added it, or maybe at the time I was thinking to use it differently... who knows.),
- the semantic URLs will be created by another class, and in case something "special" is required, it can be dealt with by adding new types.
The way the code works should be somehow easy I think, I created a function that calls the singleton (yeah, again, I know, I just didn't know where to put the darn stuff, so for the time being I stuffed it in a singleton that looks nicer that $context to me, at least for this kind of things).
The example I used is:
'url' => $scripturl . '?action=markasread;sa=all;bi;' . $context['session_var'] . '=' . $context['session_id']that becomes:
'url' => getUrl('action', array('action' => 'markasread', 'sa' => 'all', 'bi', $context['session_var'] => $context['session_id']))I'm pretty sure purist of speed will frown at the fact it needs a function call... feel free to stick with your buffer rewrite.
Of course, this is just the easy part, now the two difficult ones:
- parse the GET,
- replace all the URLs in the code base
And since 2 is massive, I decided to post it here to get some feedback regarding the code, if anyone sees problems or lacks of features, because I would like to avoid having to redo everything two times.