|
You are here: Home / Creating Custom Content Types (Collections) in Sitellite |
Creating Custom Content Types (Collections) in SitelliteAccessing Rex ProgrammaticallyThe 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 |
|
Copyright © 2010, SIMIAN systems Inc. All rights reserved. Privacy policy Some of the icons on this site were created by the Gnome Project. |