From da224828c49b4becf39bb17727fef09a3573ca25 Mon Sep 17 00:00:00 2001 From: Antonin 0x346e3730 CLAUZIER Date: Tue, 8 Nov 2022 14:30:50 +0400 Subject: [PATCH 1/2] WIP making the example module work on PS8 --- example_module_mailtheme/example_module_mailtheme.php | 4 ++-- .../views/templates/admin/index.html.twig | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/example_module_mailtheme/example_module_mailtheme.php b/example_module_mailtheme/example_module_mailtheme.php index 329609c6..0ed12df9 100644 --- a/example_module_mailtheme/example_module_mailtheme.php +++ b/example_module_mailtheme/example_module_mailtheme.php @@ -182,7 +182,7 @@ private function addLayoutToCollection(ThemeCollectionInterface $themes) $theme->getLayouts()->add(new Layout( 'customized_template', - __DIR__ . '/mails/layouts/customized_' . $theme->getName() . '_layout.html.twig', + '@Modules/example_module_mailtheme/mails/layouts/customized_' . $theme->getName() . '_layout.html.twig', '', $this->name )); @@ -211,7 +211,7 @@ private function extendOrderConfLayout(ThemeCollectionInterface $themes) $orderIndex = $theme->getLayouts()->indexOf($orderConfLayout); $theme->getLayouts()->offsetSet($orderIndex, new Layout( $orderConfLayout->getName(), - __DIR__ . '/mails/layouts/extended_' . $theme->getName() . '_order_conf_layout.html.twig', + '@Modules/example_module_mailtheme/mails/layouts/extended_' . $theme->getName() . '_order_conf_layout.html.twig', '' )); } diff --git a/example_module_mailtheme/views/templates/admin/index.html.twig b/example_module_mailtheme/views/templates/admin/index.html.twig index 2a841c06..6cec014f 100644 --- a/example_module_mailtheme/views/templates/admin/index.html.twig +++ b/example_module_mailtheme/views/templates/admin/index.html.twig @@ -1,4 +1,7 @@ -{% extends '@PrestaShop/Admin/layout.html.twig' %} +{% extends '@!PrestaShop/Admin/layout.html.twig' %} +{# Since PS 8.0.0 you can use @PrestaShopCore instead of @!Prestashop +(https://devdocs.prestashop-project.org/8/modules/concepts/templating/admin-views/#override-templates) #} +{% import '@PrestaShop/Admin/macros.html.twig' as ps %} {% trans_default_domain "Admin.Design.Feature" %} {% block content %} From 69826363b538f90275f6c17fa8759fde10ab72a5 Mon Sep 17 00:00:00 2001 From: Antonin 0x346e3730 CLAUZIER Date: Fri, 16 Dec 2022 14:32:50 +0400 Subject: [PATCH 2/2] Pass the module dir to the folder scanner that adds the dark theme --- example_module_mailtheme/example_module_mailtheme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_module_mailtheme/example_module_mailtheme.php b/example_module_mailtheme/example_module_mailtheme.php index 0ed12df9..6aa081ec 100644 --- a/example_module_mailtheme/example_module_mailtheme.php +++ b/example_module_mailtheme/example_module_mailtheme.php @@ -227,7 +227,7 @@ private function extendOrderConfLayout(ThemeCollectionInterface $themes) */ private function addDarkTheme(ThemeCollectionInterface $themes) { - $scanner = new FolderThemeScanner(); + $scanner = new FolderThemeScanner(_PS_MODULE_DIR_); $darkTheme = $scanner->scan(__DIR__ . '/mails/themes/dark_modern'); if (null !== $darkTheme && $darkTheme->getLayouts()->count() > 0) { $themes->add($darkTheme);