From kraftb at think-open.at Sat Aug 11 04:09:58 2018 From: kraftb at think-open.at (Bernhard Kraft) Date: Sat, 11 Aug 2018 04:09:58 +0200 Subject: [TYPO3-dev] Correct usage of translated records in CLI In-Reply-To: References: Message-ID: On 06/16/2018 11:05 AM, m+typo3-dev at qxio.tk wrote: > Now my problem now is that I still get the record in the main laguage > because DataMapper->mapSingleRow() (called via DataMapper->map()) has > some kind of object cache and thus returns the object in the default > language (because the uid is still the one of the record in the main > language). There is a way to invalidate the object storage cache: Make an instance of: "TYPO3\CMS\Extbase\Persistence\Generic\Session" and call the "destroy" method. This will invalidate the persistence session storage and you could fetch an object with the same uid a second time in a translated language. In fact I have posted some patches to review.typo3.org for cleaning up the "doLanguageAndWorkspaceOverlay" method. Currently it is not possible to skip either (or both) of language and workspace overlay. greetings, Bernhard From kraftb at think-open.at Sat Aug 11 04:16:12 2018 From: kraftb at think-open.at (Bernhard Kraft) Date: Sat, 11 Aug 2018 04:16:12 +0200 Subject: [TYPO3-dev] Page events/Signals/Hooks In-Reply-To: References: Message-ID: Hi, On 04/11/2018 01:11 PM, Vikram Mandal wrote: > I want to perform some action when there is any page event like new > page, edit page, even on edit page content. Where can I look/find about > this. Anyone have tried this? Any thoughts. Is there any Signals/Hooks? I would use the hooks available in "DataHandler" class: typo3/sysext/core/Classes/DataHandling/DataHandler.php The method "process_datamap" get's called for every create/update of ANY record within the BE. The method "process_cmdmap" get called for copy/move/delete/undelete operations within the BE. I guess you could hook in there. Maybe you want to have a look at my extension EXT:kb_nescefe in the extension repository. This extension allows to create contenten-element containers and therefore also hooks into the mentioned class. Maybe you can use the "kb_nescefe/Classes/Hooks/DataHandler.php" class as basis for your work. greetings, Bernhard From stefan.franke at gmx.co.uk Fri Aug 24 09:34:22 2018 From: stefan.franke at gmx.co.uk (Stefan Franke) Date: Fri, 24 Aug 2018 09:34:22 +0200 Subject: [TYPO3-dev] How to create pages/elements via Extension/Hook? Message-ID: Hello, I need to create pages/elements on the fly when saving a page record in the backend. Right now, I'm using the following code with the hook `processDatamap_preProcessFieldArray`: ----------------------------------------------------------------code starts--- $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages')->createQueryBuilder(); $queryBuilder ->insert('pages') ->values([ 'pid' => $id, 'title' => 'Subpage', 'doktype' => 1, 'urltype' => 1, 'perms_userid' => 1, 'perms_groupid' => 1, 'perms_user' => 31, 'perms_group' => 27, 'crdate' => time(), 'tstamp' => time(), ]) ->execute(); ------------------------------------------------------------------code ends--- This actually works, but I'd rather not work directly on the database. So I was wondering if there is a correct TYPO3-way of creating pages/content elements via extension/hook/etc.? I couldn't find a model for page or content element anywhere. Regards, Stefan From j.bartels at arcor.de Fri Aug 24 19:42:24 2018 From: j.bartels at arcor.de (Jan Bartels) Date: Fri, 24 Aug 2018 19:42:24 +0200 Subject: [TYPO3-dev] How to create pages/elements via Extension/Hook? In-Reply-To: References: Message-ID: Am 24.08.2018 um 09:34 schrieb Stefan Franke: > I need to create pages/elements on the fly when saving a page record > in the backend. Right now, I'm using the following code with the hook > `processDatamap_preProcessFieldArray`: > > ... > > This actually works, but I'd rather not work directly on the > database. So I was wondering if there is a correct TYPO3-way of > creating pages/content elements via extension/hook/etc.? Have a look at the DataHandler: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Typo3CoreEngine/Database/Index.html Jan From kraftb at think-open.at Sun Aug 26 13:19:07 2018 From: kraftb at think-open.at (Bernhard Kraft) Date: Sun, 26 Aug 2018 13:19:07 +0200 Subject: [TYPO3-dev] How to create pages/elements via Extension/Hook? In-Reply-To: References: Message-ID: Hi, On 08/24/2018 09:34 AM, Stefan Franke wrote: > I need to create pages/elements on the fly when saving a page record in the backend. Right now, I'm using the following code with the hook `processDatamap_preProcessFieldArray`: As you are already utilizing a hook in DataHandler I would suggest to rather use the "afterDatabaseOperation" hook therein and then make a recursive call to itself "$this->process_datamap()" to create the new entry, eventually from an template record/dataset. As you are creating pages after a page has been created you would have to take care to avoid infinite loops by using some static variable keeping the hook from being executed a second time. cu, Bernhard