I am at a position where I need a value from a resource template (either page, file, image, video etc.).
Based on that value I either need to return that resource, or redirect (to a login page, noting-found paget etc.).
I could simply register a hook for that (rout:after) and handle it from there, but the problem is that I really want this to be compatible with other plugins as well. Meaning either I need this hook to be fired first (no matter what!), or I need to manually query the url inside the route instance (without creating an infinite loop of course).
So how would one go about getting the resource from an url as it would have been if one puts it into the browsers-search bar?
What I mean is that an url might refer to a ‘page’, ‘virtula page’, ‘image’, ‘video’ etc. most can have their own template/bleuprint. So based on some complicated conditions I either want to redirect, modify or block access to that page/file/resource.
If the given path is simply a location, things wouldn’t be so complicated. But since custom routes (and hooks) may be involved I don’t want to break that mechanism. In short it would be best if I could ‘fit’ code between the actual router and the route:after hook. As I might still redirect based on the conditions (after which the rest of the hooks still may apply).
so my thinking was:
option1: have a custom route installed, but use the default system to obtain the page/file/resource for the given path so I can access its properties etc. and handle it from there;
option2: have a route:after hook, but make sure it is fired before all the others to not mess up the other hooks.
The important part is, that I don’t want to interupt/mess up other plugins’ route mechanics (as I don’t know at forehand which plugins will be installed besides the one I am currently developing).
For some extra information: url-parameters are involved in the process, so I would prefer if this could be done within a router rather than a hook, so I don’t have to ‘reparse’ the given path
Yep, that would work for regular path’s (where the url/path is the same as the directory layout). But it excludes custom route’s unfortunately. Is there some way to make a route identifiable? Because than it is solvable with the above snippit.