Open JorisDebonnet opened 6 years ago
The problem here is that the wildcard link is BEFORE the specific news
urlsegment. That means the 404 handler will be routed before your news link, hence the symptoms you've experienced.
Instead of modifying director config (harder) you should use the new extension point on Director $this->extend('updateRules', $rules);
With this extension point, you can modify the $rules in place, meaning you can do things that you couldn't do with config, such as inject rules into the middle of the array, or push / unshift new rules on either end.
Making this compatible with fluent is possible but yeah that's a whole another bunch of work. :) Look at fluent's code (extension on Director) to see how it modifies the rules.
Thanks for your comments! I tried a quick-and-dirty approach by popping off the wildcard rule, adding the datelink one, and then re-adding the wildcard rule at the end, but this still did not fix the issue.
Guess I'll need to take a different approach anyway to make it compatible with Fluent... so I'll revisit this a bit later with a Director extension.
Work in progress for #8.
Everything works except actually loading the BlogPost on that URL; it shows "Page not found".
$Links
for the BlogPosts are succesfully rewritten in the templatesrules
config for Director, ... but for some reason, the page is not in fact handled by that controller.When I
print_r(Director::config()->get('rules'))
at the end ofRegisterRoutes
, the last two entries are:I am on the URL
/news/2018/3/unrelated-news-entry/
which shows that debug info on top, but then shows an ErrorPage with "Page not found". I don't understand why it seems to be "ignoring" that it's supposed to be using the DateLinkController, which was successfully loaded into Director's rules config.How might I debug that?
(after I fix this, I may have one more question about making it compatible with Fluent, since it seems to write only one rule per localized page)