Jump to content

How to create custom admin pages (aka ProcessModules) - yes, it's that simple!


bernhard

Recommended Posts

Hello.
I confirm you that I was able to implement the panel view.
Thank you so much. I owe you a truck of beers! ?

I dare, for those who may then use the same snippet you posted, that the url of the link must be between the quotes (and in my case I also had to remove #pw-masthead, not having a specific id).

$(document).ready(function() {
  pwPanels.addPanel($("a[href='/your/admin/link/url']"));
});

I also thank @Soma for publishing this tutorial, otherwise I would sail in the deepest dark ...;)

All you are my hero! ?

P.S. My next target is to hook my restaurant menu repeater to create a button with the same link, (so editors could obtain the list in place, without scrolling to top).  If all will go right, I will share the code of the hook, the button and the List of Allergens (Hanna Code). Of course I will use your suggestion for the button... ?

Link to comment
Share on other sites

15 minutes ago, Cybermano said:

I owe you a truck of beers! ?

Well, feel free to do so - I'll happily drink them with my friends once the pandemic is over ?  http://paypal.me/baumrock

Hooking the page edit form is a lot easier:

$wire->addHookAfter("ProcessPageEdit::buildForm", function($event) {
  $form = $event->return;
  $page = $event->process->getPage();
  if($page->template != 'yourtemplate') return;

  if($f = $form->get('yourfield')) {
    $f->notes = "Show allergens <a href='/link/to/allergens' class='pw-panel'>here</a>";
    $f->entityEncodeText = false;
  }
});

 

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Update: Here's a little snippet how to use dynamic navigation items using the NavJSON feature:

// in getModuleInfo()

      'useNavJSON' => true, // enable JSON nav feature
      'nav' => [
        [
          'url' => 'contacts',
          'label' => 'Contacts',
          'icon' => 'users',
        ],[
          'url' => 'mailings',
          'label' => 'Mailings',
          'icon' => 'folder-open-o',
          'navJSON' => 'mailings-nav', // this will call executeMailingsNav() to get items
        ],[
          'url' => 'groups',
          'label' => 'Groups',
          'icon' => 'users',
        ],
      ]

// and in the module

  /**
   * JSON nav for mailings
   */
  public function executeMailingsNav() {
    $options['add'] = null; // no link to add pages
    $options['edit'] = $this->mailer()->url."new/?channel={name}";
    $options['itemLabel'] = 'label'; // use the label property as item label (default is name)
    $options['items'] = [];

    foreach($this->mailer()->channels as $channel) {
      $data = $this->wire(new WireData()); /** @var WireData $data */
      $data->name = $channel->short;
      $data->label = "New ".$channel->name;
      $data->icon = "plus-circle";
      $options['items'][] = $data;
    }

    return parent::___executeNavJSON($options);
  }

Y7W3SBZ.png

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

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