Create and Update queries are not being executed while installing our extension in the clean typo3 package

765 Views Asked by At

We have created Theme Extension in the following way:

  1. Downloaded the extension package from the site package builder(https://sitepackagebuilder.com/new/)
  2. Download and installed the TYPO3 V8.7.9 package.
  3. Then placed the extension package under the folder typo3conf/ext/ and installed the extension package in the Extension section
  4. Installed MASK and Power mail extensions because for implementing template extension we used MASK and PowerMail for form submission.

  5. Then placed the theme related templates, styles, Js, typoscript inside the extension folder.

  6. MASK content element templates are managed under the folder fileadmin//templates/content, fileadmin//templates/preview and Page content images are managed under the folder fileadmin//images, mask.json file managed under the fileadmin//. To achieve the above process, we have modified the mask backend configuration.
  7. After implementation of the theme extension, most features work except when we try to install our extension in another clean typo3 package it is not working. In order to solve, we did the following changes:

7.1. Created a new folders Initialisation, Initialisation/Extensions, Initialisation/Files under our extension folder.

7.2. Placed the dependency extension packages into Initialisation/Extensions.

7.3. Placed all the fileadmin files() into Initialisation/Files.

7.4. Modified the file ext_emconf.php to mentioned the extension details and its dependency extensions.

7.5. Placed the exported T3d pagetree file under the folder Initialisation with the name data.t3d

7.6. Added the following code in the file ext_localconf.php, for changing the mask backend configuration

<pre>
<code>
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mask'] = serialize([
'json' => 'typo3conf/ext/key-name/mask.json',
'content' => 'fileadmin/key-name/templates/content/',
'layouts' => 'fileadmin/key-name/templates/content/Layouts/',
'partials' => 'fileadmin/key-name/templates/content/Partials/',
'backend' => 'fileadmin/key-name/templates/backend/',
'layouts_backend' => 'fileadmin/key-name/templates/backend/Layouts/',
'partials_backend' => 'fileadmin/key-name/templates/backend/Partials/',
'preview' => 'fileadmin/key-name/templates/preview/',
]);
</code>
</pre>

7.7. If we add a new content element in the mask, a mask will add a new field to the tt_content table and create a new table for storing that content element values. Since this theme has too many content elements, we have added the ALTER and CREATE TABLE queries in the ext_tables.sql file. We have also added the UPDATE and INSERT queries for mask content element values.

Issue: Now the issue is, points 7.6 and 7.7(Create and Update queries are not getting executed) i.e. not working while installing our extension in the clean typo3 package.

Please let me know where we are going wrong.

Many thanks Regards Sharmistha

1

There are 1 best solutions below

6
On

This answer is based on the assumption that a "TYPO3 distribution package" shall be created. The mentioned "site package" approach in the original answer might be superfluous in case no template or backend layout definitions to render the web site frontend are being used.

Creating distribution packages for TYPO3 is briefly documented here https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/CreateNewDistribution/Index.html

General file locations of an extension are documented here https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/FilesAndLocations/Index.html - especially have a look at ext_tables_static+adt.sql which would be required to e.g. INSERT or UPDATEdata explicitly.

Concerning SQL declarations and adjustments the following explanations are important:

  • ext_tables.sql only supports declaration of tables, thus only CREATE is supported and executed - modifications like UPDATE or INSERT are not considered
  • every time an extension gets installed (or the database analyzer in the TYPO3 install tool is invoked manually) the current database schema is compared to the definitions in ext_table.sql files and adjusted (altered) in case there are differences - all ext_table.sql files of installed extensions are considered and merged at this step
  • ALTER TABLE statements are not evaluated in ext_table.sql - in case you want to adjust field declarations, use and additional CREATE statement containing new fields or the types to be altered - e.g. ext:felogin of the TYPO3 core is altering the existing tables fe_groups and fe_users in https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_8-7/typo3/sysext/felogin/ext_tables.sql
  • specific INSERT statements have to be part of the file ext_tables_static+adt.sql, see ext:extensionmanager of the TYPO3 core making use of that feature in https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_8-7/typo3/sysext/extensionmanager/ext_tables_static%2Badt.sql
  • imports in a distribution package should basically happen using the file Initialisation/data.t3d which can be created using the "Import/Export Module" as being part of the TYPO3 core package

Hope that helps. In case there are further questions, please provide error messages or warnings and describe what you wanted to achieve in particular. Thx