Jump to content

I have two modules with the same override


Recommended Posts

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

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');
            }
        }

    }

 

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...