Author Topic: Loading resource scripts in hook function  (Read 795 times)

Offline dhigz

  • Newbie
  • *
  • Posts: 35
  • Karma: +13/-0
    • View Profile
    • My AbanteCart Site:
Loading resource scripts in hook function
« on: September 03, 2020, 09:09:24 PM »
Hi,

I am attempting to add image functionality to and existing controller by loading the resource_scripts though dispatch and dispatchGetOutput like other controllers. I can add the html using addChild with no problem. The script portion is throwing an error: Call to protected method AController::dispatch() from context '...

Here is the code which is included in function onController...._UpdateData().
Code: [Select]
$resources_scripts = $that->dispatch(
            'responses/common/resource_library/get_resources_scripts',
            array(
                'object_name' => 'collections',
                'object_id'   => $id,
                'types'       => array('image'),
            )
        );
        $that->view->assign('resources_scripts', $resources_scripts->dispatchGetOutput());


Any suggestions of how I can get around this error or a different method to add the resource scripts?

Don
Don Higbee

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4251
  • Karma: +278/-9
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Loading resource scripts in hook function
« Reply #1 on: September 05, 2020, 09:46:31 PM »
If you look into public_html/core/engine/controller.php:328
Code: [Select]
protected function dispatch(...You can access/call this method.

Try to create a new instance of yourself

Code: [Select]
$resources_scripts = new ADispatcher(
            'responses/common/resource_library/get_resources_scripts',
            array(
                'object_name' => 'collections',
                'object_id'   => $id,
                'types'       => array('image'),
            )
        );

Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline dhigz

  • Newbie
  • *
  • Posts: 35
  • Karma: +13/-0
    • View Profile
    • My AbanteCart Site:
Re: Loading resource scripts in hook function
« Reply #2 on: September 07, 2020, 05:52:31 PM »
Thanks. That worked.

that was the last issues I needed to resolve.
Don Higbee

 

Powered by SMFPacks Social Login Mod