MODx CMF

onDocFormPublish, onDocFormUnpublish, onBeforeDocFormPublish, onBeforeDocFormUnpublish

Details

  • Description:
    Hide

    The right-click menu has "publish" and "unpublish" links. These events (before/after publish; before/after unpublish) are not represented in the list of available events in modx_system_eventnames.

    Note: We have the same problem with onDocFormUndelete and onBeforeDocForm Undelete, see issue MODX-189). The situation with publishing and unpublishing, though, is more complicated.

    When viewing the editing interface for a document, there is a button at the top of the page to delete it, so using a single system event (e.g. onDocFormDelete) makes sense, even though the right-click menu in the document tree never accesses the "DocForm". And even though the undelete process is not represented in the system events, a basic solution is relatively easy, and has been posted in issue MODX-189. (Though I will add that changing the "delete" button to say "undelete" when in the DocForm would be even better.)

    With publishing and unpublishing, there is no button at the top. It's a checkbox on the second page of information about the page. So the only way to publish or unpublish a document from the DocForm is by saving the document. This means that the OnDocFormSave and OnBeforeDocFormSave events are triggered, but not there is no separate process to handle events like onDocFormPublish. It doesn't exist in the DocForm at all.

    There is a separate process, though, in the right-click menu of the document tree. With this discrepancy, it might be more appropriate to call the event "OnDocPublish" rather than "OnDocFormPublish," but since publishing and unpublishing do deserve their own events, I would vote to create a button at the top for publishing and unpublishing, and removing the checkbox. This would make things more consistent overall and would allow the same event to be triggered, whether from the DocForm or from the right-click menu. If this is done, the names of the system events should include the "Doc" reference (onDocFormPublish, onDocFormUnpublish, onBeforeDocFormPublish, and onBeforeDocFormUnpublish).

    Show
    The right-click menu has "publish" and "unpublish" links. These events (before/after publish; before/after unpublish) are not represented in the list of available events in modx_system_eventnames. Note: We have the same problem with onDocFormUndelete and onBeforeDocForm Undelete, see issue MODX-189). The situation with publishing and unpublishing, though, is more complicated. When viewing the editing interface for a document, there is a button at the top of the page to delete it, so using a single system event (e.g. onDocFormDelete) makes sense, even though the right-click menu in the document tree never accesses the "DocForm". And even though the undelete process is not represented in the system events, a basic solution is relatively easy, and has been posted in issue MODX-189. (Though I will add that changing the "delete" button to say "undelete" when in the DocForm would be even better.) With publishing and unpublishing, there is no button at the top. It's a checkbox on the second page of information about the page. So the only way to publish or unpublish a document from the DocForm is by saving the document. This means that the OnDocFormSave and OnBeforeDocFormSave events are triggered, but not there is no separate process to handle events like onDocFormPublish. It doesn't exist in the DocForm at all. There is a separate process, though, in the right-click menu of the document tree. With this discrepancy, it might be more appropriate to call the event "OnDocPublish" rather than "OnDocFormPublish," but since publishing and unpublishing do deserve their own events, I would vote to create a button at the top for publishing and unpublishing, and removing the checkbox. This would make things more consistent overall and would allow the same event to be triggered, whether from the DocForm or from the right-click menu. If this is done, the names of the system events should include the "Doc" reference (onDocFormPublish, onDocFormUnpublish, onBeforeDocFormPublish, and onBeforeDocFormUnpublish).
  • Environment:
    all
  1. publish_content.processor.php
    (2 kB)
    Paul Bohman
    03/Sep/08 3:28 PM
  2. unpublish_content.processor.php
    (2 kB)
    Paul Bohman
    03/Sep/08 3:39 PM

Activity

Hide
Paul Bohman added a comment - 03/Sep/08 2:38 PM

Sorry, the last sentence should say "...the names of the system events should include the 'Form' reference..."

Show
Paul Bohman added a comment - 03/Sep/08 2:38 PM Sorry, the last sentence should say "...the names of the system events should include the 'Form' reference..."
Hide
Paul Bohman added a comment - 03/Sep/08 3:28 PM

For the sake of backward compatibility, it probably makes sense to keep the names of the existing events (OnDocPublished and OnDocUnPublished) and add to the list (OnBeforeDocPublished and OnBeforeDocUnPublished), at least for now. If the additional changes are made so that publishing/unpublishing is a button at the top rather than a checkbox in the middle of the page, it might make sense to create an alias so that either name could work.

I have uploaded an altered copy of /manager/processors/publish_content.processor.php which adds the "OnBeforeDocPublished" event.

Of course, an entry in the modx_system_settings table will also be necessary:

id: [some integer]
name: OnBeforeDocPublished
service: 5
groupname: [NULL]

My testing so far has verified that the above modification works (the event is invoked), though other changes may be necessary to make the change more useful overall.

Show
Paul Bohman added a comment - 03/Sep/08 3:28 PM For the sake of backward compatibility, it probably makes sense to keep the names of the existing events (OnDocPublished and OnDocUnPublished) and add to the list (OnBeforeDocPublished and OnBeforeDocUnPublished), at least for now. If the additional changes are made so that publishing/unpublishing is a button at the top rather than a checkbox in the middle of the page, it might make sense to create an alias so that either name could work. I have uploaded an altered copy of /manager/processors/publish_content.processor.php which adds the "OnBeforeDocPublished" event. Of course, an entry in the modx_system_settings table will also be necessary: id: [some integer] name: OnBeforeDocPublished service: 5 groupname: [NULL] My testing so far has verified that the above modification works (the event is invoked), though other changes may be necessary to make the change more useful overall.
Hide
Paul Bohman added a comment - 03/Sep/08 3:39 PM

I have uploaded a modified copy of the file manager/processors/unpublish_content.processor.php

    • IMPORTANT NOTE: THE OnDocUnPublished EVENT WAS BROKEN IN THE ORIGINAL **

There was a mismatch in the spelling ("OnDocUnPublished" in the DB vs "OnDocUnpublished" in the PHP script) in the original file. I changed the PHP script to match the database entry.

I also added a new event: OnBeforeDocUnPublished (with a capital "P" to match the other spelling), and I added a new entry to the modx_system_eventnames table.

Show
Paul Bohman added a comment - 03/Sep/08 3:39 PM I have uploaded a modified copy of the file manager/processors/unpublish_content.processor.php
    • IMPORTANT NOTE: THE OnDocUnPublished EVENT WAS BROKEN IN THE ORIGINAL **
There was a mismatch in the spelling ("OnDocUnPublished" in the DB vs "OnDocUnpublished" in the PHP script) in the original file. I changed the PHP script to match the database entry. I also added a new event: OnBeforeDocUnPublished (with a capital "P" to match the other spelling), and I added a new entry to the modx_system_eventnames table.
Hide
Paul Bohman added a comment - 04/Sep/08 10:46 AM

See related issues MODX-189, MODX-312, MODX-313

Show
Paul Bohman added a comment - 04/Sep/08 10:46 AM See related issues MODX-189, MODX-312, MODX-313

People

  • Assignee:
    Unassigned
    Reporter:
    Paul Bohman
  • Votes:
    0
    Watchers:
    1

Dates

  • Created:
    03/Sep/08 2:32 PM
    Updated:
    04/Aug/09 12:14 AM