Jump to content

How to not allow user to add child from the parent page?


adrianmak
 Share

Recommended Posts

I setup a page template which has a pageTable field.

BaiduShurufa_2016-12-29_17-42-38.png

 

To display the child page (on front-end) of the PageTable field in the parent page, user should edit the parent page and add child page within here.

BaiduShurufa_2016-12-29_17-46-37.png
However, I found that many users are likely use the "New" button from the parent's context menu. As a result, users always ask me why their child pages could not show  on the front-end.

BaiduShurufa_2016-12-29_17-48-30.png

What can I do to avoid user to add child pages from the parent's context menu ? Hide the “New" button ?
 

 

 

Link to comment
Share on other sites

Yes. A simple way would be hooking into ProcessPageListActions::getActions in your site/ready.php:

wire()->addHookAfter("ProcessPageListActions::getActions", null, "removeNewAction");

function removeNewAction(HookEvent $event) {
	$page = $event->arguments(0);
	if($page->template == "blog") {
		$actions = $event->return;
		unset($actions['new']);
		$event->return = $actions;
	}
}

 

  • Like 3
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...