[TYPO3-dev] Creating pages in Typo3 with external script
Jigal van Hemert
jigal.van.hemert at typo3.org
Tue Feb 11 07:47:57 CET 2014
Hi,
On 10-2-2014 21:59, Stephan Schuler wrote:
> I wouldn't try to inject data into the TYPO3 database without using
> the internal PHP API. There are tons of things to take care of. Like
> authors, workspace overlays, translations, history data, diffs inside of
> those history data, sorting, access privileges, maybe flex when it comes
> to different plugin inline configuration ...
True. For an import I did a two-pass method.
First pass would insert all pages below the point where the entire tree
should be imported to (TYPO3 4.x site):
/** @var $tce t3lib_TCEmain */
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->start($data, array());
$tce->process_datamap();
$newPageId = $tce->substNEWwithIDs['NEW'];
The new page ID (the TYPO3 page id) is stored with the imported record
to be able to rebuild the old page tree structure.
The second pass moves a page to the final position:
$cmd['pages'][$record['newuid']]['move'] = $parentRecord['newuid'];
...
$tce->start(array(), $cmd);
$tce->process_cmdmap();
More about using t3lib_TCEmain (in 6.x
\TYPO3\CMS\Core\DataHandling\DataHandler):
http://blog.tolleiv.de/2010/03/handling-data-in-typo3-with-tcemain/
--
Jigal van Hemert
TYPO3 CMS Active Contributor
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-dev
mailing list