pjg Posted August 7, 2013 Share Posted August 7, 2013 I've been using pw successfully for a while now and for two of my recent projects I had to rewrite the page->url function. Since rewriting this in the actual core is not great for updates it would be great if the function would generally be made hookable. This allows for a more dynamic way of dealing with links and link rendering while, as far as I can see so far, not interfering with the actual functionality of the pw core. For the time being I'm more than happy to add my 3 _ to it and with the next update do it again, but it would be useful if it was there anyway. Link to comment Share on other sites More sharing options...
Soma Posted August 7, 2013 Share Posted August 7, 2013 You would instead hook Page::path. It' used by url and making url also hookable doesn't make sense and maybe even for performance reasons as it can be called many times in a request. Or you could add your own url method to Page. Link to comment Share on other sites More sharing options...
kongondo Posted August 7, 2013 Share Posted August 7, 2013 And we have a new member...welcome to PW pjg Link to comment Share on other sites More sharing options...
SiNNuT Posted August 7, 2013 Share Posted August 7, 2013 $pages->addHookAfter('Page::path', null, 'hookPagePath'); function hookPagePath(HookEvent $e) { $page = $e->object; if($page->template == 'article') $e->return = "/blog/$page->name/"; } http://processwire.com/talk/topic/1799-routes-and-rewriting-urls/ 6 Link to comment Share on other sites More sharing options...
pjg Posted August 7, 2013 Author Share Posted August 7, 2013 For some reason hooking onto path didn't even cross my mind... sounds like the better idea though as url is dependent on path anyway and it would allow me to remove a workaround currently running for the admin pages. 1 Link to comment Share on other sites More sharing options...
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