[TYPO3-templavoila] Creating FCE manually

Xavier Perseguers typo3 at perseguers.ch
Mon Aug 4 20:58:49 CEST 2008


Hi Nikolas,

> Could you please point out the prefered way to "manually"  create a FCE
> (Ctype templavoila_pi1) based upon a given DS?.
> (manuall = from within an extension)
> 
> I had a look at the TV API but couldnt find a function to create the
> pi_flexform field. Guess that happens somewhere in TCEMAIN. 
> Any hints?

I would need the same thing and tracked down stuff until I got something:

$destinationPointer = array(
	'table'    => 'pages',
	'uid'      => 35,
	'sheet'    => 'sDEF',
	'sLang'    => 'IDEF',
	'field'    => 'field_content',
	'vLang'    => 'vDEF',
	'position' => 0, // insert at top
	'targetCheckUid' => '',	
);
		
$newRow = array(
	'CType'             => 'templavoila_pi1',
	'tx_templavoila_ds' => 2,
	'tx_templavoila_to' => 2,
);
		
$apiClassName = t3lib_div::makeInstanceClassName('tx_templavoila_api');
$apiObj = new $apiClassName('pages');
$newUid = $apiObj->insertElement($destinationPointer, $newRow);

// $newUid contains the new uid of a FCE inserted into page 35.

Now you may use this:

$row = t3lib_BEfunc::getRecord('tt_content', 41);
debug($apiObj->ds_getExpandedDataStructure('tt_content', $row));

That gives the DS of the FCE. You may then easily retrieve the list of 
fields from the structure and generate this:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3FlexForms>
     <data>
         <sheet index="sDEF">
             <language index="lDEF">
                 <field index="field_1">
                     <value index="vDEF"></value>
                 </field>
                 <field index="field_2">
                     <value index="vDEF"></value>
                 </field>
		...
                 <field index="field_n">
                     <value index="vDEF"></value>
                 </field>
             </language>
         </sheet>
     </data>
</T3FlexForms>

This is perhaps a way to investigate.

-- 
Xavier Perseguers
http://xavier.perseguers.ch/en


More information about the TYPO3-project-templavoila mailing list