Jump to content

Page::path hooks on page edit screen


Zeka
 Share

Recommended Posts

Hi.

I have hooks to Page::path like 

wire()->addHookAfter("Page(template=blog-entry|blog-category)::path", function($e) {
	$page = $e->object;
	$pages = wire('pages');
	$user = wire('user');
	$language = $user->language;
	$langSegment = $pages->get("/")->localPath($language);
	$pageName = $page->localName($language, true);
	$e->return = $langSegment . "$pageName/";
});

This hook changes pages path in frontend and 'view' action in PageTree, but it doen't in 'view' tab on page edit screen and page url in config tab of page edit screen

1213747582_2018-10-2721_38_41.thumb.png.9bb8200d89153b00023c22a8de475193.png

Is there a way (hook) how to change page path in these places? (at least view links).

Thanks, Eugene.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 years later...

Hi @Zeka

Have you found a solution for this?

We also have a hook to Page::path. After the upgrade to PW3 the view links inside the processpageedit page doesn't work anymore or better said the hook doesn't have an effect there.

KR
Orkun

Link to comment
Share on other sites

Hi @Orkun

// For view actions urls and all url for the pages
wire()->addHookAfter("Page(template=post)::path, Page(template=post)::localHttpUrl, Page(template=post)::localUrl, Page(template=post)::localPath", function($e) {
	$page = $e->object;
	$pages = wire('pages');
	$user = wire('user');
	$language = $user->language;
	$langSegment = $pages->get("/")->localPath($language);
	$pageName = $page->localName($language, true);
	$e->return = $langSegment . "$pageName/";
});

// this hook is needed to change parent path so we can get right url in link above page name field
wire()->addHookBefore("InputfieldPageName::render", function($e) {
	$inputfield = $e->object;
	$parentPageID = $inputfield->parentPage->id;

	$hookId = wire()->addHookAfter("Page(id=$parentPageID)::path", function($e) {
		$pages = wire('pages');
		$user = wire('user');
		$language = $user->language;
		$langSegment = $pages->get("/")->localPath($language);
		$e->return = $langSegment;
	});

	wire()->addHookAfter("InputfieldPageName::render", function($e) use($hookId){
		$e->removeHook($hookId);
	});
});

 

  • Thanks 1
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...