Lugi Annese Posted October 26, 2022 Share Posted October 26, 2022 hi, I have two modules with the same override. I have already read that you have to merge the two files but I could not understand how, is it possible to get help? Also, overriding both modules uses the same function override module 1 (already installed): class CmsController extends CmsControllerCore { public function initContent() { if ($this->psversion() == 7) { parent::initContent(); if ($this->assignCase == 1) { $this->cms->content = $this->returnContent($this->cms->content); $this->context->smarty->assign(array( 'cms' => $this->objectPresenter->present($this->cms), 'psver' => $this->psversion() )); if ($this->cms->indexation == 0) { $this->context->smarty->assign('nobots', true); } $this->setTemplate('cms/page', array( 'entity' => 'cms', 'id' => $this->cms->id )); } elseif ($this->assignCase == 2) { $this->context->smarty->assign($this->getTemplateVarCategoryCms()); $this->setTemplate('cms/category'); } } } module 2 override (to be installed) class CmsController extends CmsControllerCore { public function initContent () { if (Module :: isInstalled ('g_relatedcrosssellingproducts') && Module :: isEnabled ('g_relatedcrosssellingproducts')) { // overide cms content if (Tools :: getValue ('id_cms')> 0) { $ formObj = Module :: getInstanceByName ('g_relatedcrosssellingproducts'); $ this-> cms-> content = $ formObj-> getRelatedByShortCode ($ this-> cms-> content); } // # overide cms content } parent :: initContent (); } } Link to comment Share on other sites More sharing options...
endriu107 Posted October 26, 2022 Share Posted October 26, 2022 Try like that: public function initContent() { if (Module :: isInstalled ('g_relatedcrosssellingproducts') && Module :: isEnabled ('g_relatedcrosssellingproducts')) { // overide cms content if (Tools :: getValue ('id_cms')> 0) { $ formObj = Module :: getInstanceByName ('g_relatedcrosssellingproducts'); $ this-> cms-> content = $ formObj-> getRelatedByShortCode ($ this-> cms-> content); } // # overide cms content } if ($this->psversion() == 7) { parent::initContent(); if ($this->assignCase == 1) { $this->cms->content = $this->returnContent($this->cms->content); $this->context->smarty->assign(array( 'cms' => $this->objectPresenter->present($this->cms), 'psver' => $this->psversion() )); if ($this->cms->indexation == 0) { $this->context->smarty->assign('nobots', true); } $this->setTemplate('cms/page', array( 'entity' => 'cms', 'id' => $this->cms->id )); } elseif ($this->assignCase == 2) { $this->context->smarty->assign($this->getTemplateVarCategoryCms()); $this->setTemplate('cms/category'); } } } 2 Link to comment Share on other sites More sharing options...
Lugi Annese Posted October 27, 2022 Author Share Posted October 27, 2022 Should I rename the override file Internal to the module? Link to comment Share on other sites More sharing options...
joseantgv Posted November 2, 2022 Share Posted November 2, 2022 On 10/27/2022 at 10:00 AM, Lugi Annese said: Should I rename the override file Internal to the module? Yes, or you won't be able to activate the module. 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