[TYPO3-english] templavoila - update field tx_templavoila_flex using referenceElementByUid function

Jigal van Hemert jigal.van.hemert at typo3.org
Mon Jul 1 19:15:14 CEST 2013


Hi,

On 1-7-2013 11:45, Stefano wrote:
> php code that creates new pages, new content element (text) and
> insert  all this element in a typo3 tree.
>
> I use TCE_main class to create the pages and the tt_content : >
[...]
> I tried with the function "referenceElementByUid, from the class
> "tx_templavoila_api", with this code :

Why not create the content by using the TemplaVoilà API?

// array with the usual fields of a content element
$contentRecord = array(......);
// position:
// 0 - before first element
// 1 - after element #1
// 2 - after element #2
// ...
// -1 after last element
$position = -1;
// Name of the field in the page template the CE will be placed
$fieldName = 'field_content';

$templaVoilaApiObject = new tx_templavoila_api;
$destinationPointer = array(
	'table' => 'pages',
	'uid' => $pageId,
	'sheet' => 'sDEF',
	'sLang' => 'lDEF',
	'field' => $fieldName,
	'vLang' => 'vDEF',
	'position' => $position
);
$elementUid = $templaVoilaApiObject->insertElement(
	$destinationPointer,
	$contentRecord
);
// $elementUid is either the UID of the newly created CE or
// FALSE if the operation was not successful

TemplaVoilà contains tests for all kinds of operations like inserting 
content elements, FCEs, moving elements around, placing items inside 
FCEs, etc. They are excellent for learning to use the API.

see: test/tx_templavoila_api_testcase.php

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-english mailing list