Workflow controls how changes to versioned content are made available on the front-end.

An additional boolean parameter is added to the getX functions, by convention called $approvedOnly, which if true will retrieve the current live version rather than the working copy.

function getCustomThing($id, $approvedOnly = false)
    if ($approvedOnly) {
        $versions = new Versions(ABOUT_TABLE, $this->id);

        $liveVersion = $versions->getLiveVersion();

        if ($liveVersion !== null) {
            return $liveVersion;

For more specific examples of the $approvedOnly flag refer to /jadu/websections files.

Adding workflow to Control Center files

To get the approved version of an items of content, do the following. Add the following include:


Ensure the following Javascript/CSS files are available on the page:


Copy the logic to approve the latest version:

if (isset($_POST['approve'])) {
    $task = getAdminTask($_POST['taskID']);
    if ($THIS_WORKFLOW->id == -1 || $ADMIN_MUST_APPROVE) {
        // to create a new version and save any changes they may have made
        $vs = new Versions($task->dbTable, $task->objectID);

Copy the form elements to submit for approval:

    if (awaitingWebmasterAproval(ABOUT_TABLE, $about->id)) {
        $admin = getAdministrator($adminID);
        $task = getAwaitingWebmasterAprovalTask(ABOUT_TABLE, $about->id);

        if ($task->adminID == $adminID) {
    <td class="generic_desc">
        <em><?php print $stepCounter++; ? >.</em> <p>Submit for approval</p>
    <td class="generic_action">
        <input type="hidden" name="taskID" value="<?php print $task->id;?>">
        <input type="submit" class="button" name="approve" value="Approve"
                onclick="return approveTask(<?php print $task->id;?>);">
        <input type="button" class="button" name="reject" value="Reject"
                        '<?php print $task->id;?>',
                        '<?php print ADMIN_TASK_ACTION_REJECT; ? >',
                        '<?php print encodeHtml($task->pageTitle) ?>',
                        '<? php print $THIS_WORKFLOW->id; ?>',
                        '<?php print encodeHtml($_SERVER['QUERY_STRING']); ?>')" />

Finally, we need to enable workflow on this content type so that we can build custom workflows around it. To do this find the record for the main content type page in JaduModulePages database table and set the workflow flag to 1. This should be the parent page, for example News rather than News Item.

results matching ""

    No results matching ""