Jump to content

Release: SchedulePages


formmailer

Recommended Posts

Hm, I just realize that I can only check if a page is saved as “unpublished”. But I can’t catch that moment when a published page is saved for the first time with the “Unpublished: Not visible on site” checkbox checked, so that the page is now unpublished. Or can I?

If I add the rule I thought of (see below), this would mean that saving an unpublished page – whether it has ever been published or not – with a publish_from date which is older than the current timestamp.

if ($page->is(Page::statusUnpublished) && $page->template->hasField('publish_from') && $page->publish_from < $currenttime) {
    $this->session->error($this->_("“Publish From Date” field was cleared because it contained a date which lies in the past. This would have caused the page to be (unintentionally) published resp. re-published on the next Lazy Cron run. Obviously this was not your intention since you chose to only save and not publish the page."));
    $page->publish_from = null;
    $page->save('publish_from');
}

As a consequence a user would no longer be able to save a new page as “unpublished” with a publish_from date which lies in the past.

Comparison:

  • With the current version of the module this new and unpublished page will be published resp. re-published on the next cron run.
  • With the additional code above the publish_from field is cleared, the page will thus remain unpublished and an error message informs the user about what happend.

I think this behavior is more logical than the current one. But it definitely changes the way the module handles publishing dates from the past on unpublished pages. So if some users rely on the present behavior as part of their workflow, they would have a bit of a problem.

Link to comment
Share on other sites

Maybe like this:

$page->isChanged("status") && $page->is(Page::statusUnpublished);

Thank you! That’s it. I should read the cheat sheet more conscientiously.

In combination with adding an additional hook before the $pages->save it works like a charm.

Pull request for module version 1.2.1 is already out:

https://github.com/formmailer/SchedulePages/pull/9

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

I wondered why the module wasn't working on included pages (like tablefield pages). I thought this to be a bug, it's not.

The module actually works!  - What actually was the problem was: The find section for identifying the pages which need work could include an "include=hidden". 

So all the hidden pages also benefit from this great feature. - Endless possibilities! :-)

UPDATE: Forget this message: Adding include=hidden makes no difference. I simply had a problem with my cache. Sorry. Is scheduler honoring the ProCache on status changes?

Link to comment
Share on other sites

  • 1 month later...

The modules does use standard datetime fields, therefore if other datetime fields do suffer from the same issue it's probably a core issue.

Here's what solved the problem for me. Left page original settings of the auto generated publish fields, right page are my modification of the settings. no more "hh" and "ss" strings and the page scheduling works now 

post-620-0-89765800-1453974552_thumb.jpg

so maybe for some reasons time formating options that need to be choosen was missed by the auto generated post_from/post_until fields, which i did'nt touched since creation.

  • Like 3
Link to comment
Share on other sites

  • 3 months later...
  • 5 months later...

I found a conflict with PW 3:

I could not duplicate a page from the page tree. Messages on page tree page (default Admin):

Bildschirmfoto 2.png

Bildschirmfoto.png

Maybe some checks about the publishing should be left out when a page is just beeing duplicated.

I.m.h.o the publish_from and publish_until fields should be simply cleared for the fresh duplicate (even if required)?

(Or is this something I need to report as PW issue?)

Link to comment
Share on other sites

Looks like I have made the following patch locally:

-        if ($page->isChanged('status') && $page->is(Page::statusUnpublished) && $page->publish_from) {
+        if (!$page->isNew() && $page->isChanged('status') && $page->is(Page::statusUnpublished) && $page->publish_from) {

Possibly related :)

  • Like 3
Link to comment
Share on other sites

  • 3 years later...
On 1/28/2016 at 10:50 AM, Chris said:

Here's what solved the problem for me. Left page original settings of the auto generated publish fields, right page are my modification of the settings. no more "hh" and "ss" strings and the page scheduling works now 

post-620-0-89765800-1453974552_thumb.jpg

so maybe for some reasons time formating options that need to be choosen was missed by the auto generated post_from/post_until fields, which i did'nt touched since creation.

Thanks for this.
I want to show this error for better search results: WireDateTime: The parsed time was invalid

  • 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
×
×
  • Create New...