Post by oli-infa » Mon Jul 27, 2020 6:57 pm

Hello,
I am working with events in opencart 2.3.0.2, I have created a module with 2 events in it, the first one is an admin trigger and is working fine but the second is targeting catalog/controller/common/header/after where I want to add a variable before it is passed to the view, this does not seem to working as I am getting an undefined variable test from the view, could anyone point me in the right direction please.

Code: Select all

    class ControllerExtensionModuleVonderevents extends Controller {


          public function install()
          {

            $this->load->model('extension/event');
            $this->model_extension_event->addEvent('Add_Vonder_Admin_Menu', 'admin/view/common/column_left/before', 'extension/module/vonderevents/addMenuItems');//works fine
            $this->model_extension_event->addEvent('Update_Vonder_Catalog_Header', 'catalog/controller/common/header/after', 'extension/module/vonderevents/updateCatalogCommonHeader');//does not work!

          }//end function

          public function uninstall() {
            $this->load->model('extension/event');
            $this->model_extension_event->deleteEvent('Add_Vonder_Admin_Menu');
            $this->model_extension_event->deleteEvent('Update_Vonder_Catalog_Header');
        }


          // add the vonder menu items
          public function addMenuItems($route, &$data)
          {
                $data['menus'][] = array(
                'id'       => 'menu-vonder',
                'icon'     => 'fa-bicycle',
                'name'     => 'Vonder Management',
                'href'     => '',
                'children' => array(
                        array(
                            'name'=> 'Home Page Options',
                            'href'=> $this->url->link('extension/module/vonderoptions', 'token=' . $this->session->data['token'], true),
                            'children'=> array()
                        ),
                )
            );

          }//end function addMenuItems


          public function updateCatalogCommonHeader($route, &$data)
          {
                  $data['test']= '********************************';

                echo "*****************************************";

          }//end function updateCatalogCommonHeader





    }//end class

Newbie

Posts

Joined
Wed Jul 22, 2020 4:44 pm

Post by straightlight » Mon Sep 07, 2020 10:53 pm

Correct. OC v3.x releases handles controllers from the loader Engine with the events, not under.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by DigitCart » Mon Sep 07, 2020 11:28 pm

Hi

Did you create this file?
catalog/controller/extension/module/vonderevents.php

Is there a updateCatalogCommonHeader method in this file?

My Extensions / DigitCart


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm

Who is online

Users browsing this forum: No registered users and 17 guests