[TYPO3] Is there a copy row or dulpicate row function?

Anders Tillbeck at at opengate.dk
Thu Jun 7 21:14:20 CEST 2007


I took a while. At first it did not work since the be_user I was logged 
in as did not have the neccesary rights. I found out when trying to 
execute my code as admin and that worked :-)

I may end up having to use this to execute code as admin using:
$tce->start($data,$cmd,$alternative_BE_USER);


But for now my working example is to do something like this:

class tx_myextension_pi1 extends tslib_pibase {
	... ...
	function main($content,$conf)	{
		$uid = 56; // uid of tt_content that shall be copied
		$to_page_id = 7; // where to place copy of tt_content
		if($this->copy_tt_content($uid,$to_page_id)) {
		$content .= 'ok to insert new tt_content<br />';
		}
	}

	// Insert new tt_content
	function copy_tt_content($uid,$to_page_id) {
		require_once (PATH_t3lib.'class.t3lib_tcemain.php');
		$tce = t3lib_div::makeInstance('t3lib_TCEmain');
		$tce->stripslashes_values=0;
		$data['cmd']['tt_content'][$uid]['copy']=$to_page_id;
		$tce->start($data['data'],$data['cmd']);
		$tce->process_datamap();
		$tce->process_cmdmap();
		return true;
	}
	... ...
}


But now I ended up with a different problem. The tt_content that is 
inserted into $to_page_iud is inserted as a "non-used element". For now 
I have to go back into the page module and insert the newly created 
"non-used element" into the page.

BR. Anders


More information about the TYPO3-english mailing list