[TYPO3-english] templavoila - update field tx_templavoila_flex using referenceElementByUid function
Stefano
denebola75 at yahoo.it
Mon Jul 1 11:45:12 CEST 2013
Hello.
My name is Stefano Danieli and I am working to a 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 :
This the code :
$code = "NEW_" . uniqid('');
$code_en = "NEW_" . uniqid('');
$code_content = "NEW_" . uniqid('');
$data['pages'][$code]['pid'] = 157;
$data['pages'][$code]['title'] = $N_DOCENTE;
$data['pages'][$code]['hidden'] = 0;
$data['pages'][$code]['description'] = $K_DOCENTE;
$data['pages'][$code]['perms_everybody'] = 31;
$data['pages'][$code]['tx_templavoila_ds'] = 6;
$data['pages'][$code]['tx_templavoila_to'] = 5;
$data['pages_language_overlay'][$code_en] = array();
$data['pages_language_overlay'][$code_en]['pid'] = $code;
$data['pages_language_overlay'][$code_en]['title'] = $N_DOCENTE;
$data['pages_language_overlay'][$code_en]['sys_language_uid'] = 1;
$data['pages_language_overlay'][$code_en]['hidden'] = 0;
$data['pages_language_overlay'][$code_en]['doktype'] = 1;
$data['pages_language_overlay'][$code_en]['cruser_id'] = 1;
$data['tt_content'][$code_content]['pid'] = $code;
$data['tt_content'][$code_content]['header'] = "Scheda Docente";
$data['tt_content'][$code_content]['CType'] = 'text';
$data['tt_content'][$code_content]['bodytext'] = "Text"
$data['tt_content'][$code_content]['hidden'] = 0;
$data['tt_content'][$code_content]['deleted'] = 0;
$data['tt_content'][$code_content]['colPos'] = 0;
/* using tce_main class */
$tce=t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;
$tce->admin = 1;
$tce->start($data, array());
$tce->process_datamap();
This code works ok : my problem is that I want the tt_content element just created was also referenced into the pages, so the content appears normally in my content area :
I tried with the function "referenceElementByUid, from the class "tx_templavoila_api", with this code :
require_once(t3lib_extMgm::extPath('templavoila') . 'class.tx_templavoila_api.php');
$templavoilaApiObj = t3lib_div::makeInstance('tx_templavoila_api');
$destinationPointer = array(
'table' => 'pages',
'uid' => $content_key, // the uid of my page
'sheet' => 'sDEF',
'sLang' => 'lDEF',
'field' => 'field_content',
'vLang' => 'vDEF',
'position' => 0
);
$templavoilaApiObj->referenceElementByUid($content_value,$destinationPointer))
But the content is still unlinked (it appears as unlinked element in backend) :
the XML in "tx_templavoila_flex" field in table "PAGE" doesnt' contain the UID of the content element.
<value index="vDEF"> **** missing UID OF TT_CONTENT **** </value>
What am i doing wrong?
Sorry for my bad english.
Thank you in advance for reply.
S.
More information about the TYPO3-english
mailing list