Jump to content

Publish New Pages by Default in Admin Interface


SwimToWin
 Share

Recommended Posts

The basic Processwire workflow assumes that I (as an Editor) want to save new Pages in draft mode - and therefore new pages are always set to unpublished by default. To publish the page, it is necessary to actively press "Publish", otherwise the Page will not be visible.

The workflow is:

  1. Add new Page
  2. Status is now "Unpublished: Not visible on site."
  3. Press Publish - the page is now visible on site

I want to publish pages right away (without having to press Publish).
Where is that configured?

ProcessWire 3.0.123
Uikit v3 admin theme (0.3.0)

Link to comment
Share on other sites

You may rename the Save and Publish buttons... ?

The first "save" only creates the page in page tree and assigns the template to it. You can not actually enter any content upon page creation, so keeping the page unpublished seems very reasonable to me. Maybe the Save button could be named "Create" to better reflect what happens. At this moment the page really should not be published automatically, since it may contain required fields, where your template code rely on.

With the template assigned, you'll have fields to enter content and see the Publish button. After entering the data you press "Publish", which effectively is "Save+Publish" in this case. I don't see an extra step to publish a page after entering its content, since this already is the default.

Only in case the selected template does not have additional fields you'll see additional Save+Publish buttons. Are we talking about this situation?

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Putting this in your ready.php or admin.php should do it. You may want to add additional checks for admin only (not via API).

$this->addHookAfter('Pages::added', function($event) {
    $p = $event->arguments[0];
    $p->removeStatus('unpublished');
    $p->save();
});

But, @Autofahrn has some excellent points about publishing a page which doesn't have any content other than the title, so use this with caution!

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Excellent suggestions. Thanks to all.
@adrian, your solution works like a charm:

  1. Press New
  2. Set Title and Name (Template is currently unassigned)
  3. Press "Save" - Page now gets published with the chosen template, all template fields are blank.

Setting pages to unpublished is still possible.
This is how I want the flow.

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

×
×
  • Create New...