Jump to content

Add Page Shortcut Menu

Recommended Posts

Hi Guys

I have a question about the Add Page Shortcut Functionality. In General you can set the family settings on template so that you have to choose a new Parent when adding a new page of the defined template with the shortcut menu. In my case I can add new "Newsletter" Pages but I have to choose under which Parent it should be added. But as a "Clinic" - User I can only add the Newsletter Pages under the Parent Page which belongs to this User (was made with a Hook inside Page::addable / Page:editable).  Because of that I only see one Parent Item in the Dropdown Shortcut Menu which is correct.


Can this Selection be skipped when the shortcut menu only has one Parent to choose (Also in ProLister "Add New")?

Share this post

Link to post
Share on other sites

Do I have to make a hook inside ProcessPageAdd::___executeTemplate or something like that? 

Share this post

Link to post
Share on other sites

This worked for me:

I'm doing a "addHookBefore" inside the ProcessPageAdd::executeTemplate Method.

public function init() {

     if(!$this->user->isSuperuser() && $this->user->hasRole("XXXXXXXX")) $this->addHookBefore('ProcessPageAdd::executeTemplate', $this, 'redirectParent');


Inside the redirectParent Hook Method

public function redirectParent(HookEvent $event){

     //Get ID from URL
     $templateID = (int) $this->input->get->template_id;

     //Check if it's a Newsletter
     if($templateID == 66){
          //Get the Parent Page specified by the choose_sender_2016 Pagefield in the user & newsletter Template
	  $parent = $this->pages->get("template=newsletter-clinic, choose_sender_2016={$this->user->choose_sender_2016}");
          //Check if a Parent was found
                //Skip the Parent Selection with a redirect
		$url = "./?parent_id=" . $parent->id; 
	        if($this->wire('input')->get('modal')) $url .= "&modal=1";

  • Like 3

Share this post

Link to post
Share on other sites

Interesting - I was just dealing with something similar with AdminRestrictBranch but solved it a different way by hooking into executeNavJSON

Here's the approach just it's helpful for you or someone else: https://github.com/adrianbj/AdminRestrictBranch/blob/master/AdminRestrictBranch.module#L110

PS - I am certainly not suggesting mine is better in anyway - just a different approach to share :)

  • Like 2

Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By louisstephens
      So I ran into a very strange issue today. I have a template with a pagetable and I went to add an item to it, when I went to select an image (for an image field) the page instantly threw up an error
      "ProcessPageSearchLive: No search specified"
      The page's content also switched to the image attached. This all worked perfectly last week (local mamp box). Has anyone experienced this before, and how did you solve it?

    • By Pip
      Hi everyone, 
      Is there a way for us to replicate the "http://mydomain.com/processwire/page/edit/?id=xxx" and change the template to match my site template? 
      I'm terribly happy with the admin / backend page edit. It covers literaly everything I want to empower my non super admin user in updating pages such as validation, repeater management, file upload. 
      I wish not to allow the users to see the backend for both security and aesthetic reasons. 
      Thanks and hope to hear from you soon. 
    • By EyeDentify
      Hello dear PW gurus.

      I have stumbled over a strange error that i all of sudden got when trying to upload an image to a images field on a page.
      There where images allready stored in the field that i wanted to keep, but during the upload the error apear and after that all images are gone from the field and i can´t upload any, i just get the error every time.
      I am running ProcessWire 3.0.153 dev.
      After looking in the assets folder i find the folder for the page and the image files seems to be there including the ones i tried to upload when the error occured.
      But they don´t show up in the images field in the page editor.
      The error reported:
      SQLSTATE[01000]: Warning: 1265 Data truncated for column 'ratio' at row 1 And here is a screenshot of the event:

      The TracyDebugger Error reporting:

      I hope you fine folks could point me in a direction.
      But it seems our old pal set_time_limit() is back.

      Regards, EyeDentify
    • By Spyros
      I'm having a strange issue with the $page->find(), for some reason I'm missing some of the pages from the results. I found then that I was missing all the pages with the same "PAGE NAME". Is it a bug or am I missing something?
      If I change the "PAGE NAME" of one of the missing ones then I'm retrieving the page without any problem.
      Thank you
    • By benbyf
      Hi, Looking to create form elements on a page–some input with a colection of form inputs and the appropriate labels and variables for that input. I've used ProForms in the past and rolled out my own when creating simply one off forms, but I wonder if anyone has found a good way of allowing form creation on page editing so that clients can adhocly make and edit forms?
  • Create New...