Username:
Password:
    Forgot your password?
Member Login

Workflow In Sitellite

Notes

Chat Loading chat status
  • Please subscribe to chat.
  • Older messages can be viewed in the chat archive.

Subscribe  |  The Lounge  |  Share Lesson

Chapter 3: The workflow service box

Let's create a box to perform the service of saving our contact data to a database table with the following schema. You can create this database table by pasting this into the SQL Shell in the DB Manager.

create table myapp_contact_submission (
	id int not null auto_increment primary key,
	name char(72) not null,
	email char(72) not null,
	submitted_on datetime not null,
	message text not null,
	index (submitted_on, email, name)
);

The workflow service box, saved to inc/app/myapp/boxes/services/contact/submission/index.php, could be as simple as this:

<?php

db_execute (
	'insert into myapp_contact_submission
		(id, name, email, submitted_on, message)
	values
		(null, ?, ?, now(), ?)',
	$parameters['data']['name'],
	$parameters['data']['email'],
	$parameters['data']['message']
);

?>

Now all we need to do is connect our box to the event by telling Sitellite about it. To do this, we need to add a service.php file to our new service box folder. This file will look like this:

; <?php /*

name = myapp_contact_submission
actions = contact
title = Myapp Contact Submissions
summary = Logs all contact form submissions to the database.

; */ ?>

We also need to add one line to the bottom of our app's conf/config.ini.php file to say that this app contains workflow services:

workflow = yes

Now, we should see our new service available in the Workflow Services in the Sitellite Control Panel. Check it off and hit Save to have your box be installed into the appropriate configuration file. In this case, that file would be inc/app/cms/conf/services/contact.php, which would then look something like this:

; <?php /*

[service:myapp_contact_submission]

name = Myapp Contact Submissions

handler = "box:myapp/services/contact/submission"

; */ ?>
If we execute our form and submit the test data, we should see the entry appear in our database table if we view it in the DB Manager.

Chapter 4: Standard parameters »