Ivan Gretsky Posted Tuesday at 04:30 PM Posted Tuesday at 04:30 PM Good day! I have a module that sets a url hook. But then I have code in site/ready.php that stops page rendering process under certain conditions based on a page being viewed. So I need to modify that condition to include all url/path hooks. How do I do it? I thought of setting a custom $config variable. Or checking for $config->requestPath(). But maybe there is something universal?
adrian Posted Thursday at 02:30 PM Posted Thursday at 02:30 PM I actually came across the need for this as well. @ryan - could we perhaps have: $page->isUrlHook In my case I have url segments enabled on the homepage and some logic to process them, but that logic can't tell if it's a urlsegment or a path created by a URL hook. I ended up with this for now: $urlHookSegments = []; $pathHooks = $wire->hooks->pathHooks ?? (new \ReflectionProperty($wire->hooks, 'pathHooks'))->getValue($wire->hooks); foreach ((array) $pathHooks as $hook) { $match = $hook['match'] ?? ''; if (preg_match('#^/([^/{(]+)#', $match, $m)) { $urlHookSegments[$m[1]] = true; } } if ($input->urlSegment1 && !isset($urlHookSegments[$input->urlSegment1])) { 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now