meyer2005 Posted May 20, 2020 Share Posted May 20, 2020 Hello, I want to clone the contactform module in prestashop 1.7.6.5. I did the following steps, but apparently it is not enough. I receive error. Can you help me please? ------------------------------- 1. Copy the existing module contactform and rename to it for contactform-home /public_html/modules/contactform /public_html/modules/contactform-home 2. Change related file name: /public_html/modules/contactform/contactform.php /public_html/modules/contactform-home/contactform-home.php 3. Change the class name of copied module class to Contactform-home class Contactform-home extends Module implements WidgetInterface 4. Change the modules name in the class constructor public function __construct() { $this->name = 'contactform-home'; 5. Change the parameter name SEND_CONFIRMATION_EMAIL = 'CONTACTFORM_SEND_CONFIRMATION_EMAIL'; --> SEND_CONFIRMATION_EMAIL_HOME = 'CONTACTFORM_SEND_CONFIRMATION_EMAIL_HOME'; const SEND_NOTIFICATION_EMAIL = 'CONTACTFORM_SEND_NOTIFICATION_EMAIL'; --> const SEND_NOTIFICATION_EMAIL_HOME = 'CONTACTFORM_SEND_NOTIFICATION_EMAIL_HOME'; 6. Change the module name,and display name in config.xml. /public_html/modules/contactform-home/config.xml <name>contactform-home</name> <displayName><![CDATA[Contact form home]]></displayName> 7. rename contactform.tpl to it for contactform-home.tpl /public_html/modules/contactform-home/views/templates/widget/contactform.tpl 8. Copy the existing ContactController and rename to it for ContactController-home /public_html/controllers/front/ContactController-home.php public $php_self = 'contact-home'; public function initContent() { ..... $this->setTemplate('contact-home'); } $breadcrumb['links'][] = [ .... 'url' => $this->context->link->getPageLink('contact-home', true), ]; Link to comment Share on other sites More sharing options...
JBW Posted May 20, 2020 Share Posted May 20, 2020 Dash is not allowed in class names - choose a different name Link to comment Share on other sites More sharing options...
JBW Posted May 20, 2020 Share Posted May 20, 2020 BY the way, this is the German part of the forum Link to comment Share on other sites More sharing options...
meyer2005 Posted May 20, 2020 Author Share Posted May 20, 2020 Hallo JBW, vielen Dank für Deine Antwort, tatsächlich der Fehler lag daran.Fehler wurde nach Korrektur behoben. Ich habe mein neues Modul "contact form Home" in HomeDisplay-Hook, da ich den Kontakt-formular auch an der Startseite haben möchte, erscheint aber nicht auf der Startseite. Hättest Du evt. einen Tipp für mich!? PS: Es tut mir leid, dass ich auf englisch (das war ja kein englisch...nur google translation von meinem schlechten deutschen Text) geschrieben habe,ich habe gedacht, meine Frage würde dadurch mehr Leute erreichen können. Link to comment Share on other sites More sharing options...
JBW Posted May 20, 2020 Share Posted May 20, 2020 27 minutes ago, meyer2005 said: Ich habe mein neues Modul "contact form Home" in HomeDisplay-Hook, da ich den Kontakt-formular auch an der Startseite haben möchte, erscheint aber nicht auf der Startseite. Mit dem standard Modul funktioniert das ohne Probleme. Da es ein "Widget" ist kannst du es eigentlich in jedem Hook anzeigen lassen. Funktioniert es den überhaupt auf irgendeiner anderen Position? Hast du die .tpl Datei hier im display auch umbenannt auf deinen neuen Namen? public function renderWidget($hookName = null, array $configuration = []) { if (!$this->active) { return; } $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); return $this->display(__FILE__, 'views/templates/widget/contactform.tpl'); } Link to comment Share on other sites More sharing options...
meyer2005 Posted May 20, 2020 Author Share Posted May 20, 2020 (edited) Nein, funktioniert leider auf keiner anderen Position. Die .tpl Datei heisst contactformHome.tpl und in der Datei ContactformHome.php habe ich angepasst return $this->display(__FILE__, 'views/templates/widget/contactformHome.tpl'); Das funktioniert trotzdem nicht. Muss ich evt. in der DB was ändern? Oder in der neuen Datei ContactHomeController!? class ContactHomeControllerCore extends FrontController { public $php_self = 'contactHome'; public $ssl = true; /** * Assign template vars related to page content. * * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->setTemplate('contactHome'); } public function getBreadcrumbLinks() { $breadcrumb = parent::getBreadcrumbLinks(); $breadcrumb['links'][] = [ 'title' => $this->getTranslator()->trans('Contact us', [], 'Shop.Theme.Global'), 'url' => $this->context->link->getPageLink('contactHome', true), ]; return $breadcrumb; } } Edited May 20, 2020 by meyer2005 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now