0
votes

I'm using TYPO3 7.x LTS. I've added a custom table with a TCA entries for it. Each record of this table has a pid set to the corresponding page. However, when page is deleted, TYPO3 automatically removes records in my table that are associated with that page. This is fine, I guess, but I'm in a situation where I can't loose those records.

Is there a nice way to tell TYPO3 to not delete records from my table along with a page? I've studied the TCA reference documentation but I found nothing there.

I'm looking for something like enableCascadingDelete option which is available for an inline type of fields.

I know I can define a delete column, which will be updated instead of record being removed but this solution is not elegant.

The other not elegant solution I can think of would be to set the rootLevel => 1 on the table and introduce another field, like page_id or something.

Is there an elegant solution for my problem?

1

1 Answers

2
votes

As you already found out, there is 'enableCascadingDelete' for inline, only.

The concept for pages is different here: In TYPO3 everything is located on some page. This means if a page is deleted, records on this page have to be deleted, too. Even if you wouldn't delete the affected records, you wouldn't be able to edit this record in the backend anymore. That's one of the reasons that if you delete a page, records on this page are soft or hard deleted, too.

This basically means: If you have some db table with TCA that can edited in the backend, it belongs to some page, and thus will be deleted if you delete the page.

Maybe rethink your record storage concept a bit: A casual use case is to have records on a different page (usually a page of type Folder). This is good practice for instance with "news" records, "frontend users" and so on. The introduction package does it like that, for instance. Then, on your main web pagetree that is rendered in the frontend have plugins and tell them where they should find their records. Many plugins (read: all good plugins) then accept a storage folder configuration for this. If you then set up access rights in a sane way, you can prevent non-admin users from deleting your record storage folders, while they still can manipulate (eg. delete) web pages in the backend, and your records (eg. news) wouldn't be deleted along with the page since they are located at a different place.