adrian

Admin Actions

60 posts in this topic

Small update that:

1) lets you add:

protected $noBackup = true;

to your action class to prevent backups (either automatic or from showing the option to backup). This is handy if your action doesn't do any DB writing in which case a backup isn't relevant.

2) lets you populate:

$this->output = 'Content for output';

to your executeAction() method. Whatever content is in this will be returned before $this->successMessage and won't be formatted with the green background. This is useful if your action queries and displays info.

Hope you guys find these useful.

 

PS - still waiting on the first PR for a user contributed action :)

1 person likes this

Share this post


Link to post
Share on other sites

EDIT: Solved this by myself, see bottom of the post.

Hi @adrian First of all, this is a really great and useful module. I want to submit the id of a page to my custom module, but I don´t want to show up the id as a field that is being shown. Right now I call the module via 

admin-actions/options?action=BewerbungsunterlagenAnfordern&id=1514

And this is my defineOptions function

        protected function defineOptions()
        {
            $missingFiles = array();
            foreach ($this->pages->get("/unterlagentypen")->children as $unterlage) {
                $missingFiles[$unterlage->id] = $unterlage->title();
            }


            return array(
                array(
                    'name' => 'missingFiles',
                    'label' => 'Fehlende Unterlagen',
                    'description' => 'Wählen Sie aus, welche Unterlagen noch benötigt werden.',
//                    'notes' => 'Only use one of "Pages" or "User Roles"',
                    'type' => 'AsmSelect',
                    'options' => $missingFiles,
                    'required' => true,
//                    'requiredIf' => 'pages=""'
                ),
                array(
                    'name' => 'id',
                    'label' => 'ID der Bewerbung',
                    'description' => 'Bitte den Inhalt dieses Feldes nicht ändern.',
                    'type' => 'Text',
                    'required' => true,
                ),

            );

        }

How can I hide the ID Field?

Just set the type to "hidden" and Voilá :)

1 person likes this

Share this post


Link to post
Share on other sites

@adrian Hi Adrian,

here are two thoughts how to improve this great module.
Remove the "<p>The '.$actionName.' action was completed successfully.</p>" in line 250 or only print it, if no custom successMessage was set.
Because one may only want to display his own messages.
Use ProcessWires $this->message or $this->error function instead of an own messaging function, so it has the "native" ProcessWire behaviour that people are used to
 

Share this post


Link to post
Share on other sites

Hi @jmartsch - good idea - I have changed it so that message is only displayed if there is no custom message defined.

As for using $this->message or $this->error - I don't see any reason why you can't already use those if you prefer - please test and let me know. The reason I went with the other approach is to allow for a larger and more obvious response than the standard PW message/error interface provides.

If you need any additional tweaks on this front, please detail them out for me. I didn't spend a lot of time on this part of the module because it was initially designed for superuser use, although I am myself starting to make actions available to other roles, so I would like to improve this experience.

Cheers,
Adrian

Share this post


Link to post
Share on other sites

@adrian Your addition with the permission "admin-actions-hide-menu" hides the menuitem for the specific role/user, but it also disables the access to the module for this user group. I logged out and in again. If I remove the permission for the role, I can access the module.

Share this post


Link to post
Share on other sites

@adrian It would be nice if you add an option to hide the "Action Code" fieldset. Maybe make it only visible to superusers. But I think an option to hide it for all users would be better.

EDIT: Because it really is not important and irritating to normal users when this is being shown.

Share this post


Link to post
Share on other sites
5 hours ago, jmartsch said:

@adrian Your addition with the permission "admin-actions-hide-menu" hides the menuitem for the specific role/user, but it also disables the access to the module for this user group. I logged out and in again. If I remove the permission for the role, I can access the module.

Ah, you're right - sorry about that - shouldn't do things in a rush. I think I am going to remove that option from the module completely. I'll see if I can find some time to answer the issue of hiding menu items another way in your other thread.

3 hours ago, jmartsch said:

@adrian It would be nice if you add an option to hide the "Action Code" fieldset. Maybe make it only visible to superusers. But I think an option to hide it for all users would be better.

EDIT: Because it really is not important and irritating to normal users when this is being shown.

It is only visible for superusers - is it still an issue for you knowing that?

Share this post


Link to post
Share on other sites
2 minutes ago, adrian said:

Ah, you're right - sorry about that - shouldn't do things in a rush. I think I am going to remove that option from the module completely. I'll see if I can find some time to answer the issue of hiding menu items another way in your other thread.

It is only visible for superusers - is it still an issue for you knowing that?

It would be nice to hide it from superusers as well, because superuser != programmer/developer

Share this post


Link to post
Share on other sites
59 minutes ago, jmartsch said:

It would be nice to hide it from superusers as well, because superuser != programmer/developer

Ok, there is now a new config option that needs to be checked to show the action code. 

 

On an unrelated note, I also revamped the revamped the recent $noBackup option. This is a breaking change, but now you can set:

protected $dbBackup = 'automatic' (or 'optional', or 'disabled') 

in your custom actions to override the default behavior as defined in the module config settings.

Hopefully this will be a helpful change.

1 person likes this

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 FIA2008
      How can I change the output of `Page::render`?
      I've created a hook before page::render, but when I set the $event->return to something else, my whole page is replaced with that value.
      For example:
       
      public function beforePageRender(HookEvent $event) { $event->return = 'blaat'; } This will cause my whole page to be nothing more than just 'blaat'.
      What I want, is that my menu, footer etc. are still visible but only the content of that page is replaced.
    • By kixe
      Today I have been running in mysql errors using @renobird s Module MarkupActivityLog which still uses mysqli Driver.
      @all developers
      Although mysqli is still supported PDO driver is the default database driver in PW since https://processwire.com/about/news/introducing-processwire-2.4/
      and its strongly recommend to all module authors to use/change-to PDO driver instead of mysqli.

      @renobird I have sent a pull request.
       
    • By Nurguly Ashyrov
      NOTE: This thread originally started in the Pub section of the forum. Since we moved it into the Plugin/Modules section I edited this post to meet the guidelines but also left the original content so that the replies can make sense.  
      ProcessGraphQL
      ProcessGraphQL seamlessly integrates to your ProcessWire web app and allows you to serve the GraphQL api of your existing content. You don't need to apply changes to your content or it's structure. Just choose what you want to serve via GraphQL and your API is ready.
      Warning: The module supports PHP version >= 5.5 and ProcessWire version >= 3.
      Links:
      Zip Download Github Repo ScreenCast  
      At this moment the module is not available from the modules section. Please refer to the Readme to learn more about how to use the module.
       
      Original post starts here...
      Hi Everyone! I became very interested in this GraphQL thing lately and decided to learn a bit about it. And what is the better way of learning a new thing than making a ProcessWire module out of it! 
      For those who are wondering what GraphQL is, in short, it is an alternative to REST. I couldn't find the thread but I remember that Ryan was not very happy with the REST and did not see much value in it. He offered his own AJAX API instead, but it doesn't seem to be supported much by him, and was never published to official modules directory. While ProcessWire's API is already amazing and allows you to quickly serve your content in any format with less than ten lines of code, I think it might be convenient to install a module and have JSON access to all of your content instantly. Especially this could be useful for developers that use ProcessWire as a framework instead of CMS.
      GraphQL is much more flexible than REST. In fact you can build queries in GraphQL with the same patterns you do with ProcessWire API.
      Ok, Ok. Enough talk. Here is what the module does after just installing it into skyscrapers profile.

      It supports filtering via ProcessWire selectors and complex fields like FieldtypeImage or FieldtypePage. See more demo here
      The module is ready to be used, but there are lots of things could be added to it. Like supporting any type of fields via third party modules, authentication, permissions on field level, optimization and so on. I would love to continue to develop it further if I would only know that there is an interest in it. It would be great to hear some feedback from you. I did not open a thread in modules section of the forum because I wanted to be sure there is interest  in it first.
      You can install and learn about it more from it's repository. It should work with PHP >=5.5 and ProcessWire 3.x.x. The support for 2.x.x version is not planned yet.
      Please open an issue if you find bugs or you want some features added in issue tracker. Or you can share your experience with the module here in this thread.
    • By Macrura
      Released:
      http://modules.processwire.com/modules/jquery-ion-range-slider/
      The built in rangeslider is good, but it is somewhat limited if you need really specific slider interfaces, like with pips and showing the value on the handles.
      There are many Jquery rangesliders, but one of the best and easiest to implement is the ion.rangeSlider.
      http://ionden.com/a/plugins/ion.rangeSlider/en.html
      This is a preview of the very simple module that basically allows you to enable the ion.Rangeslider on any text input, and then you type in your params into the textarea field (careful, you can break the page's javascrpt if you are not careful!) There are way too many options to really make this configurable, so the easiest way it to have a free text field where you enter any params. The params are just passed to the instance of the slider.
      Features of ion.Rangeslider:
      Skin support. (5 skins included and PSD for skin creation) Any number of sliders at one page without conflicts and big performance problems Two slider types single (1 slider) and double (2 sliders) Support of negative and fractional values Ability to set custom step and snap grid to step Support of custom values diapason Customisable grid of values Ability to disable UI elements (min and max, current value, grid) Postfixes and prefixes for your numbers ($20, 20 € etc.) Additional postfix for maximum value (eg. $0 — $100+) Ability to prettify large numbers (eg. 10000000 -> 10 000 000 or 10.000.000) Slider writes its value right into input value field. This makes it easy to use in any html form Any slider value can be set through input data-attribute (eg. data-min="10") Slider supports disable param. You can set it true to make slider inactive Slider supports external methods (update, reset and remove) to control it after creation For advanced users slider has callbacks (onStart, onChange, onFinish, onUpdate). Slider pastes all its params to callback first argument as object Slider supports date and time  
      Screenshots comparing Inputfield Rangeslider (Soma) vs. JqueryIonRangeSlider...
      1) basic range using currency
      '
      Same with different skin

      Range of years

      Same with narrower column and different skin..

       
      the module is functional and being used on 1 site, but some additional testing is needed...
    • By FIA2008
      I'm using PHPdocumentor to generate documentation of my modules, but it fails to scan the .module files. Is there another way of making processwire see a module other than giving it a .module extension?
      I'd like to rename my module file to .php but then processwire no longer sees my module.