About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

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

Creating Custom Content Types (Collections) in Sitellite

Accessing Rex Programmatically

The following are some code samples using the Rex API to perform the most common Rex-related tasks.

The Basics

<?php

loader_import ('cms.Versioning.Rex');

$rex = new Rex ('sitellite_page');
if (! $rex->collection) {
	die ('Collection not found!');
}

?>

Retrieving a Document

<?php

// 'test_page' is the primary key value
$document = $rex->getCurrent ('test_page');

info ($document);

?>

Creating a Document

<?php

$vals = array (
	'id' => 'test_page',
	'title' => 'Test Page',
	'body' => 'Testing...',
	'sitellite_status' => 'approved',
);

$res = $rex->create ($vals, 'Document added.');

if (! $res) {
	die ($rex->error);
}

?>

Updating a Document

<?php

$vals = array (
	'id' => 'test_page',
	'title' => 'Test Page',
	'body' => 'Test two...',
	'sitellite_status' => 'approved',
);

$method = $rex->determineAction ($vals['id'], $vals['sitellite_status']);
if (! $method) {
	die ($rex->error);
}

$res = $rex->{$method} ($vals['id'], $vals, 'Document updated.');

if (! $res) {
	die ($rex->error);
}

?>

Deleting a Document

<?php

$rex->delete ('test_page');

?>

Generating a Form

<?php

class MyappAddForm extends MailForm {
	function MyappAddForm () {
		parent::MailForm ();

		$rex = new Rex ('sitellite_page');

		$widgets = $rex->getStruct ();
		if (! $widgets) {
			die ($rex->error);
		}

		$this->widgets = array_merge ($this->widgets, $widgets);
	}
}

?>

Revision Histories

<?php

$history = $rex->getHistory (
	'test_page',
	false, // retrieve full documents or just the primary key
	10, // limit
	0 // offset
);

info ($history);

?>


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

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 © 2010, SIMIAN systems Inc.
All rights reserved. Privacy policy
Some of the icons on this site were created by the Gnome Project.