Jump to content

Recommended Posts

Posted

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/

Posted
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...

Posted

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
Posted
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
Posted
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);

 

Posted
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:

image.png.59d32f8c91ad4cb8db50ab80f77b62e6.png

Posted
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 ?

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
  • Recently Browsing   0 members

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