phpopencart-3opencart-modulejournalopencart-events

What are the correct routes to use for Opencart events when using the Journal3 Theme


I made a really simple Opencart Extension, using the event system, and ran it on a test server. It worked with the default theme, so now I am trying to modify it to run on an Opencart server with Jurnal3 installed. Now, when I install it, I get 2 internal server errors. Other nearly identical extensions from other developers install and run fine. So I believe something must be wrong with my event registration. I am using Opencart 3.0.3.3 and Journal3.

My install function looked like this initially:

public function install()
{
    $this->load->model('setting/event');
    $this->model_setting_event->addEvent('insertheadercode', 'catalog/view/common/header/before', 'extension/module/pagefixes/insertpagestyle');
    $this->model_setting_event->addEvent('inserttwigcode', 'catalog/view/product/product/before', 'extension/module/pagefixes/inserttwigcode');

}

I also tried this:

$this->model_setting_event->addEvent('insertheadercode', ‘catalog/view/theme/journal3/template/common/header/before’, 'extension/module/pagefixes/insertpagestyle');
$this->model_setting_event->addEvent('inserttwigcode', 'catalog/view/theme/journal3/template/product/product/before', 'extension/module/pagefixes/inserttwigcode');

What would be the correct route to register these events for the Journal3 theme?


Solution

  • Watch out for typos. In the line class ControllerExtensionModuleMyExtension extends Controller { at the top of my controller, I misspelled the file name MyExtension. The default routes seem to be valid for Journal3 at least for the product page. Like so:

        $this->model_setting_event->addEvent('inserttwigcode', 'catalog/view/product/product/before', 'extension/module/pagefixes/inserttwigcode');