Jump to content
SwimToWin

Publish New Pages by Default in Admin Interface

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)

Share this post


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

Share this post


Link to post
Share on other sites

if you have $config->advanced = true in your site/config.php file, then you'll see some addtl. fields in template > advanced:

dont-allow-unpublished-pages.PNG.e93c5a081d46abe7fe414962f3bfbe8b.PNG

Although I would also be careful with that.

  • Like 2
  • Thanks 1

Share this post


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

Share this post


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

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 codevark
      The Minimal Site works fine, but if I try to login as admin, I have no idea what the credentials are.
      I did not do the "install" process myself. The OVA came with everything set up, but there's no mention of the PW admin credentials being set to some initial value.
      Wondering if anyone else has tried the Bitnami OVA and if there's a simple answer.
      --Pete
    • By vwatson
      I don't have any fontawesome icons in the admin section. Not sure what's wrong. They used to appear. I've tried all the user profiles and they're gone in all of them.
      Using the browser inspector tool, I see this message:
      Access to font at 'https://www.domain.com/wire/templates-admin/styles/font-awesome/fonts/fontawesome-webfont.ttf?v=4.7.0' from origin 'http://domain.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
      I'm not sure why this is occurring or how to fix it. Any help would be greatly appreciated. 
    • By Andi
      Getting a little deeper into the ProcessWire state-of-mind here. I seriously think I wouldn't have come back to webdev if it wasn't for this wonderful little gem of a CMS.
      I have an "Options" field added to all users on a site. If the user has anything other then "default" selected, I would like to show a permanent message in the admin like the one in the screenshot, only so that the user can't close it. As a friendly reminder that he changed that option from default to something crazy 🙂
      I've read up on how to send messages to users, but where would I hook into to make this show up all the time in the backend?
      https://processwire.com/api/ref/wire/message/
      Thanks in advance!

    • By BitPoet
      Here's a small new module that adds a "Manage tags" button to the template list, just like the field list already has.
      Easily add, remove and change tags for your templates.
      https://github.com/BitPoet/TemplateTagsEditList

    • By Noel Boss
      👋 PW Pros…
      I have some hooks that I need to bind at the init phase (or even __construct) and I was wondering, and I couldn't find a good and simple way to determine if I'm in the admin. Would be nice if there is a reliable short option to do so, but I can't seem to find one… Is there a coherent way to tell this no matter where I am?
      Right now, I use the following method inside one of my modules:
      public function isAdmin($page = null) { if ( strpos($this->input->url, $this->urls->admin) !== false || $this->process instanceof ProcessPageList || $this->process instanceof ProcessPageEdit || ($page instanceof Page && $page->rootParent->id == $this->config->adminRootPageID) ) { return true; } return false; } @ryan wouldn't it be nice to have something like wire()->isAdmin(); like wire()->user->isLoggedin(); to tell if we are in admin – very early on (probably even in __construct() phase of modules?
×
×
  • Create New...