About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / Creating Custom Content Types (Collections) in Sitellite

Creating Custom Content Types (Collections) in Sitellite

Supplimentary Rex APIs

Locking: cms.Workflow.Lock

The cms.Workflow.Lock package provides a simple locking mechanism you can use to prevent multiple editors from accessing the same document at the same time. Note that the default add and edit forms already provide locking automatically.

The following is an example of the Lock package in action:

<?php

loader_import ('cms.Workflow.Lock');

lock_init ();

if (lock_exists ('sitellite_page', 'index')) {
    echo template_simple (
        LOCK_INFO_TEMPLATE,
        lock_info ('sitellite_page', 'index')
    );
} else {
    lock_add ('sitellite_page', 'index');
}

// do your business...

lock_remove ('sitellite_page', 'index');

?>

As you can see, it's easy to add locking capabilities to your Sitellite-based applications. More information about the Lock package can be found in the inc/app/cms/lib/Workflow/Lock.php file.

Undo

The cms.Versioning.Undo package provides a simple way of providing an undo mechanism (ie. basic transactional capabilities) for Sitellite app developers.

The following is an example of the Undo class in action:

<?php

// import the Undo class
loader_import ('cms.Versioning.Undo');

// create a new Undo object
$undo = new Undo ();

// we'll use the app name, the action name, and the current username
// to create a unique identifier for our Undo data.
$name = 'myApp:someAction:' . session_username ();

// some sample data
$data = array ('one' => 'mississippi', 'two' => 'mississippi');

// store a revision of our data
$res = $undo->save ($name, $data, 'testing undo package');
if (! $res) {
	// save() failed
    die ($undo->error);
}

// retrieve the revision we just stored
$lastChange = $undo->getLast ($name);
if (! $lastChange) {
	// getLast() failed
    die ($undo->error);
}

// output the data retrieved from getLast()
print_r ($lastChange->body);

// remove all revisions
$undo->clear ($name);

?>

As you can see, Undo is a straight-forward abstraction of Rex, created with the aim of removing the complexity and providing only the bare essentials. More information about Undo can be found in the inc/app/cms/lib/Versioning/Undo.php file.

Streamer

The cms.Versioning.Streamer package provides a means of accessing Rex collections through PHP's standard file and directory functions.

The following is an example of the Streamer package in action:

<?php

// grab revision #5 from the index page
$fp = fopen ('rex://sitellite_page/index#5');

// grab the page title for the index page
$title = file_get_contents ('rex://sitellite_page/index/title');

// grab the current index page
$fp = fopen ('rex://sitellite_page/index');

if (! $fp) {
    die ('fopen failed!');
}

while (! feof ($fp)) {
   echo fgets ($fp);
}

fclose ($fp);

// open all draft pages as a directory listing
$dh = opendir ('rex://sitellite_page?sitellite_status=draft');

// return a search for "install" as a directory listing
$d = dir ('rex://sitellite_page?body[like]=%install%');

if (! $d->handle) {
    die ('dir failed!');
}

while (false !== ($file = $d->read ())) {
    echo $file . "\n";
}

$d->close ();

?>

More information about Streamer can be found in the inc/app/cms/lib/Versioning/Streamer.php file.

Conclusion

As you've seen, Sitellite's content collections are an easy way to achieve a lot of content management power with little to no coding required. Collections also provide the flexibility needed in larger content management deployments, including document versioning, access control, multi-faceted searching, locking, automatic SiteSearch integration, and more.



Page 1: Creating a Rex Collection
Page 2: The Database Schema
Page 3: The Collection Definition File
Page 4: The Collection Definition File (Continued)
Page 5: Accessing Rex Programmatically
Page 6: Supplimentary Rex APIs

All Tutorials

Members

Note: You can use your SitelliteForge.com account here and vice versa.

Username

Password

Forgot your password?

Not a member? Click here to register

Sitellite 5 Beta


Copyright © 2008, SIMIAN systems Inc.
All rights reserved. Privacy policy
Some of the icons on this site were created by the Gnome Project.