Some steps into the workflows

A workflow is a sequence of predefined operations assigned to the system, to a user, or to a user group, that have to be executed in a predefined order.

This functionality can be used—for example—to create an approval procedure for articles, or to notify a user when a particular event happens.

eZ Publish allows the creation of workflows, and assigns them to triggers in order to easily manage tasks and, moreover, to provide us with an API for creating custom workflows for our extensions.

The default workflow events

eZ Publish exposes five default workflow events:

  • Approve
  • Wait until date
  • Multiplexer
  • Simple Shipping
  • Payment Gateway

All of these can be used together in a cascade to create complex behavior, or can be used one-by-one to provide simple event management.

Approve

The Approve event will block a particular section from being published. In this event, you can choose if a user (or group) can be excluded, and who will approve new content.

Wait until date

This event filter requires a date attribute to be present in the chosen object class. This event will override the default publishing date specified by a user with the one defined in the workflow.

Multiplexer

This filter is very useful for combining different workflows together. It can be used to filter sections, classes, or users that other workflows run against.

Simple Shipping

This is used to add, for example, a new value for shipping costs in the e-commerce site. This cost will be added to the total cost of goods that the user has purchased.

Payment Gateway

This filter is used to manage the logic behind a payment gateway. To work, it should be used in conjunction a third-party payment gateway extension.

Creating a notification workflow

We will now create a workflow that will allow a specific editor (the editor chief who inherits from the Administrator group roles) to approve new content that is published in the blog by others editors.

Note

Notification workflow

If you want to create a workflow notification system, the easiest way is to download and install the eZ Information extensions from the eZ System Projects site.

You can find more information here: http://projects.ez.no/ezinformation

As the first step, we have to open the Setup tab and go to the Workflow link at the bottom of the left-hand sidebar.

Creating a notification workflow

By default, eZ Publish creates an empty Standard workflow. We will open it and create a new workflow by using the New workflow button.

Creating a notification workflow

Next, we will compile the new workflow and name it as Approve blog. We will add an Event / Multiplexer choice from the select form by using the Add event button, as shown in the following screenshot:

Creating a notification workflow

Now, we have to filter the objects/sections where we want to enable our new workflow. To do this, we have to complete the multiselect input fields, using the default value for all of the fields, except for Classes, in order to run the workflow, where we select both the Blog and Blog post values.

Creating a notification workflow

We will also select Administrator users in the Users without workflow IDs multiselect field, to make sure that the administrator's posts will not need to be approved.

After that, we have to create a new workflow based on an approve event filter. As before, create a new workflow inside the Standard workflow group by clicking on the New workflow button. Next, we will create a new event workflow, named approving system, by selecting Event / Approve.

Creating a notification workflow

Because the blog doesn't belong to any particular section, we will choose the All sections value for the Affected sections form. We will not pay attention to the languages because we want to moderate all of them, but we will choose Publishing new object in the Affected versions area.

Creating a notification workflow

We have to enable the users or groups that need to approve the new content. We will choose the Administrator users group and also select this group in the following Excluded user groups area.

Next, we will save our new workflow by clicking on the OK button.

Creating a notification workflow

Next we have to re-edit the Approve blog workflow and select the approving system workflow as the Workflow to run. This will ensure that every time the Approve blog starts, the approve event will be executed for the correct object classes.

The next step is to assign our new multiplexer workflow to a particular event. To do this, we will use the Triggers function which is located in the menu of the Setup tab of the administration area.

Creating a notification workflow

For the content module of the publish before function, we can now choose the workflow we just created (Approve blog). Next, we will click on the Apply changes button to enable it.

The workflow is enabled and every time that the editor tries to publish a new blog post, the new Approve blog workflow will be triggered and the user will see a message that alerts him or her that their new post is pending for approval. The administrator can then approve the new content from the My account tab from the My pending items link.

Tip

The workflow engine works only in the background, and you can run it by adding the /var/www/packtmediaproject/ezpublish.cron file to your system crontab.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.79.65