typo3 versioning

June 15th, 2006

I have just done some initial research into how to use typo3’s versioning api, especially in regards to previously existing extensions. Here is what I’ve found, in summary.

To add versioning capabilities to an existing table of an extension.

ext_tables.php:

$TCA[”user_localdev_stores”] = Array (
“ctrl” => Array (

‘versioningWS’ => TRUE,
‘origUid’ => ‘t3_origuid’,

ext_tables.sql: (right after the cruser_id line)

CREATE TABLE user_localdev_stores (

t3ver_oid int(11) DEFAULT ‘0′ NOT NULL,
t3ver_id int(11) DEFAULT ‘0′ NOT NULL,
t3ver_wsid int(11) DEFAULT ‘0′ NOT NULL,
t3ver_label varchar(30) DEFAULT ‘’ NOT NULL,
t3ver_state tinyint(4) DEFAULT ‘0′ NOT NULL,
t3ver_stage tinyint(4) DEFAULT ‘0′ NOT NULL,
t3ver_count int(11) DEFAULT ‘0′ NOT NULL,
t3ver_tstamp int(11) DEFAULT ‘0′ NOT NULL,
t3_origuid int(11) DEFAULT ‘0′ NOT NULL,

that’s it. make those two adjustments, and your records will now have that nifty “v” versioning icon.

2)

Now, if you want your extension to DO things with versioning, such as create a new version of a record automatically, e.g. when a FE user submits a form, here are some classes to reference:

t3lib_BEfunc->selectVersionsOfRecord() and others in t3lib_BEfunc
t3lib_page->versionOL() and others in t3lib_page
t3lib_TCEmain->insertNewCopyVersion()
!! t3lib_TCEmain->versionizeRecord() and others in t3lib_TCEmain
t3lib_TCEmain->insertDB($table,$id,$fieldArray,$newVersion=FALSE,$suggestedUid=0,$dontSetNewIdIndex=FALSE)
t3lib_TStemplate->versionOL() ??
t3lib_userAuthGroup

It looks like TCEmain is a class that I need to spend some time in!

3 Responses to “typo3 versioning”

  1. david Says:

    Updates:

    TCEmain is the class, but there are at least a couple of ways to use it.

    Page 460 of the Packt typo3 book has some information. Probably the best reference is the Core API doc. (doc_core_api). They both say you can instantiate the class, then call methods on it.

    Method 1:

    require_once (PATH_t3lib.”class.t3lib_tcemain.php”);
    $tce = t3lib_div::makeInstance(’t3lib_TCEmain’);
    $tce->stripslashes_values = 0;
    $tce->start($data,$cmd);
    $tce->process_datamap();
    $tce->process_cmdmap();

    Method 2:

    ALSO! there are two “gateway” scripts to TCEMain:
    typo3/tce_db.php
    typo3/tce_file.php
    They accept form submissions directly. But these are generally considered alternative forms of processing data. Method 1 is preferred.

  2. Dmitry Dulepov Says:

    Do not use thse functions directly, they are internal and do not do all that you need for versioning:
    t3lib_TCEmain->insertNewCopyVersion()
    t3lib_TCEmain->versionizeRecord() and others in t3lib_TCEmain
    t3lib_TCEmain->insertDB

    You need to feel command array properly (see typo3/mod/use/ws/class.wslib.php) and execute TCEmain to work with versioning. Only this way or you risk become incompatibile with future versions!

  3. david Says:

    Dmitry,

    Will those functions work when called from the frontend? via a plugin?

Leave a Reply