Je dois insérer dans la base de données joomla de mon site. En particulier, dans la table mail_templates. Mais, il m'est impossible d'y arriver et je n'ai pas de message d'erreur.
Voici le code des différents fichiers.
File: insertiondt.php
file: insertiondt.xml
file: update-1.0.0.sql
Voici le code des différents fichiers.
File: insertiondt.php
Code:
<?php defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Plugin\CMSPlugin; class plgInsertionDataCompliance extends CMSPlugin { public function onExtensionAfterInstall($installer, $eid){ if ($eid === 'plg_insertiondatacompliance') { $this->onMyEvent(); } } public function onMyEvent() { // Obtenez une connexion à la base de données $db = Factory::getDbo(); $columns = array('template_id', 'extension', 'language', 'subject', 'body', 'html_body', 'attachments', 'params'); $values = array('com_datacompliance.admin_admin', 'com_datacompliance', '', 'FOO', 'BAR', '<p>BAR</p>', '', '{"tags":["name","email","username","registerdate","lastvisitdate","requirereset","resetcount","lastresettime","activation","block","id","actions","actions_text"]}'); $query = $db->getQuery(true) ->insert($db->quoteName('#__mail_templates')) ->columns($db->quoteName($columns)) ->values(implode(',', $db->quote($values))); $db->setQuery($query); $db->execute(); } }
Code:
<?xml version="1.0" encoding="UTF-8"?> <extension method="upgrade" group="datacompliance" type="plugin" version="1.6"> <name>InsertionDataCompliance</name> <version>1.0.0</version> <creationDate>May 2022</creationDate> <author>BMD!</author> <authorEmail>bmdpro@gmail.com</authorEmail> <authorUrl>http://www.joomlathat.com</authorUrl> <copyright>2022 joomlathat.com</copyright> <license>GNU General Public License v2</license> <description>InsertionDataCompliance</description> <files> <filename plugin="InsertionDataCompliance">insertiondt.php</filename> <folder>sql</folder> </files> <languages> <!--language tag="en-GB">languages/en-GB.plg_invoices_payment_paypal.ini</language--> </languages> <update> <schemas> <schemapath type="mysql">sql</schemapath> </schemas> <files folder="sql"> <file type="sql">update-1.0.0.sql</file> </files> </update> </extension>
Code:
INSERT INTO #__mail_templates (template_id, extension, subject, language, body, htmlbody, attachments, params) VALUES ('tempid', 'extension', '','Sujet du mail', 'Corps du mail', '<p>p</p>', '', '{}');
Commentaire