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

Anders Tillbeck at at opengate.dk
Mon Jun 4 12:48:52 CEST 2007


Hi Sander

Thanks for your post. I had no time to try it out until last night 
(sunday). It seems that the links you posted should contain the info 
that I need ;-)

So far I have had no luck but have only worked with it a couple of 
hours. I will give try it out again tomorrow (tuesday) and will post my 
findings here.

I am trying to insert data into the tt_content table in a frontend 
plugin. There is a be_user logged in at the time.

As a test I have tried to create a page since this example is given in 
the docs you posted a link to and also copy a row in tt_content:

// prepare copy tt_content.uid.56 and set pid=7
$cmd['tt_content'][56]['copy'] = 7;

// prepare creating page as first page in parent page.uid.4
$data['pages']['NEW9823be87'] = array(
     "title" => "The page title",
     "subtitle" => "Other title stuff",
     "pid" => "4"
);

// Include class and call methods
require_once (PATH_t3lib.'class.t3lib_tcemain.php');
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;

// execute copy of tt_content
$tce->start(array(),$cmd);
$tce->process_cmdmap();

// execute creation of page
$tce->start($data,array());
$tce->process_datamap();
t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
$tce->clear_cacheCmd('pages');


But, until now it seems not to work for me.

BR. Anders




Sander van Gelderen skrev:
> Hi Anders,
> 
> I wonder if my tip was any good for you? I am still struggling with my 
> problem, but it would be of some help to me to know if this worked for you.
> 
> Cheers,
> 
> Sander
> 
> Sander van Gelderen schreef:
>> Hi Anders,
>>
>> take a look at 
>> http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.1.0/view/3/3/ 
>>
>>
>> I think you need to use $tce->process_cmdmap();
>>
>> Note: I have not used it myself yet but am currently working on a 
>> similar problem (see my post today  "t3lib_TCEmain hook 
>> processCmdmap_postProcess")
>>
>> HTH,
>>
>> Sander
>>
>>
>> Anders Tillbeck schreef:
>>> I am doing an extension where I need to create a copy of a tt_content 
>>> element from one page to another and only changing pid.
>>>
>>> Is there a way to copy a table row and insert it into the same table 
>>> with a new auto_increment uid? I have not a function for that purpose 
>>> but have the feeling I have not been looking the righ place.
>>>
>>> I have searched the ExtDevEval to show DB functions:
>>> http://typo3.org/typo3conf/ext/extdeveval/apidocs/t3lib_db.html
>>>
>>> It is basically the same functionality as in the backend when copying 
>>> a content element and inserting a copy on the same or another page.


More information about the TYPO3-english mailing list