bernhard Posted August 31, 2018 Share Posted August 31, 2018 From time to time I find myself adding custom api methods/properties like this one: /** * get http edit url */ $this->addHookProperty('Page::httpEditUrl', function($event) { $event->return = $this->wire->pages(2)->httpUrl . 'page/edit/?id=' . $event->object->id; }); Or this one for $page->httpsUrl, where I started a PR: https://github.com/processwire/processwire/pull/116 What do you think? Have you ever come across any needed page url variants. It might be better to collect all of them and create a aggregated PR? This is what we have so far: https://processwire.com/api/ref/page/ Link to comment Share on other sites More sharing options...
Soma Posted August 31, 2018 Share Posted August 31, 2018 Ever tried: $page->editUrl(true); 3 1 Link to comment Share on other sites More sharing options...
bernhard Posted August 31, 2018 Author Share Posted August 31, 2018 1 hour ago, Soma said: $page->editUrl(true); Thx, totally missed/forgot that ? Anyhow, I think there are other shortcuts missing (eg httpsUrl or functions to return the whole query string, host, scheme etc). I'll post back if I stumble over the next one... Link to comment Share on other sites More sharing options...
adrian Posted August 31, 2018 Share Posted August 31, 2018 One thing I would like to see is editUrl work properly for users, roles, permissions, templates, and fields. Currently the first 3 kind of work, but they take you to page/edit/?id= instead of /access/users/edit/?id= etc. 1 Link to comment Share on other sites More sharing options...
Soma Posted August 31, 2018 Share Posted August 31, 2018 8 minutes ago, bernhard said: Thx, totally missed/forgot that ? Anyhow, I think there are other shortcuts missing (eg httpsUrl or functions to return the whole query string, host, scheme etc). I'll post back if I stumble over the next one... If you set an explicit protocol on the template, $page->httpUrl() will return correct https if set. $input->httpUrl(true); Will return the full requested url with protocol and query string / url segments. 1 Link to comment Share on other sites More sharing options...
Soma Posted August 31, 2018 Share Posted August 31, 2018 2 minutes ago, adrian said: One thing I would like to see is editUrl work properly for users, roles, permissions, templates, and fields. Currently the first 3 kind of work, but they take you to page/edit/?id= instead of /access/users/edit/?id= etc. This return the correct url for me $user->editUrl(true); Link to comment Share on other sites More sharing options...
adrian Posted August 31, 2018 Share Posted August 31, 2018 1 minute ago, Soma said: This return the correct url for me $user->editUrl(true); Sorry, yes you're right about $user, but it doesn't work for the other examples I listed, eg: Link to comment Share on other sites More sharing options...
bernhard Posted August 31, 2018 Author Share Posted August 31, 2018 8 minutes ago, Soma said: If you set an explicit protocol on the template, $page->httpUrl() will return correct https if set. Yep, thx, I'm aware of that, but in my case I needed an url with forced HTTPS independent from the template setting. 9 minutes ago, Soma said: Will return the full requested url with protocol and query string / url segments. Thx again. I'll wait for an explicit example to see if anything is missing or I was just not reading the docs carefully enough ? 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