Search code examples
content-management-systempublishingeditingconcrete5

Concrete5 isEditMode()-like handler to get Information about active editing or publishing


So my question is if there is a Concrete 5 handler/listener instead of

isEditMode() 

that tells if the user is in active Editing mode or if he just has published his Edit?

Something like

isPublished() or isEditModeActive()

Thx yall


thanks for your interest!

So i tried the Eventhandler in the way it is decumented in the second example: 1. i created site_events.php in the /config 2. i added

<?PHP Events::extendPageType('inhalt', 'on_page_version_approve');?>
  1. i added to the site.php

    define('ENABLE_APPLICATION_EVENTS', true);

  2. on the reffered inhalt.php pagetype i added

    function on_page_version_approve() { echo "page published"; }

... nothing happens. In the description it is written, that the refferring inhalt.php has to exist in /controllers. However, this is not the case. I actually dont quite understand the structure of the Eventhandling. It would be great if you could help me out there... Thanks in advance anyways :)


Solution

  • It sounds like you want what concrete5 calls Events (http://www.concrete5.org/documentation/developers/system/events/).

    As per the docs, you'll get the Page as arguments to the functions you register.

    There is nothing quite as specific as what you're looking for, but:

    1. For published, use on_page_version_approve.
    2. For editing, try on_before_render. It's a bit generic (ie, it'll be getting called far more than you're interested), but you can do something like if ($page->getCollectionCheckedOutUserID()). You should experiment a bit with this, though. For example, if you check out the home page for editing, and then someone else loads the live version, the event will probably get called again, and the Page will probably show "checked out". But maybe you can check ->isEditMode(), which should check it against the logged in user...