Jump to content

do we need more url/httpUrl options?


bernhard
 Share

Recommended Posts

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

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

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.

  • Like 1
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...