Author Topic: extend or hook  (Read 6701 times)

Offline natdroid

  • Full Member
  • ***
  • Posts: 113
  • Karma: +36/-3
    • View Profile
extend or hook
« on: March 20, 2019, 07:25:51 AM »
How to extend or replace function with my own in /core/engine/controller.php ?


https://github.com/abantecart/abantecart-src/blob/master/public_html/core/engine/controller.php#L392

Any help would be greatly appreciated.

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: extend or hook
« Reply #1 on: March 20, 2019, 07:36:08 AM »
Please explain what the aim?
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline natdroid

  • Full Member
  • ***
  • Posts: 113
  • Karma: +36/-3
    • View Profile
Re: extend or hook
« Reply #2 on: March 20, 2019, 07:45:13 AM »
thank you
I build extension and want to catch and remove .css and .js in templates .tpl
Code: [Select]
<script type="text/javascript" src="<?php echo $this->templateResource('/javascript/jquery-1.12.4.min.js'); ?>"></script>

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: extend or hook
« Reply #3 on: March 20, 2019, 09:08:14 AM »
hmm...
may be better to create empty file /javascript/jquery-1.12.4.min.js inside of your  extension?

$this->templateResource() is a method of AView class, not AController.

It looking into extensions for needle first

Code: [Select]
    public function templateResource($filename, $mode = 'http')
    {
        if (!$filename) {
            return null;
        }
        $http_path = '';
        $res_arr = $this->_extensions_resource_map($filename);
....

“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline natdroid

  • Full Member
  • ***
  • Posts: 113
  • Karma: +36/-3
    • View Profile
Re: extend or hook
« Reply #4 on: March 20, 2019, 09:14:10 AM »
how do I need to hook to $this->templateResource in my extension/core/extension.php ?

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: extend or hook
« Reply #5 on: March 20, 2019, 11:32:23 AM »

may be better to create empty file /javascript/jquery-1.12.4.min.js inside of your  extension?


Did you already tried this?
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline natdroid

  • Full Member
  • ***
  • Posts: 113
  • Karma: +36/-3
    • View Profile
Re: extend or hook
« Reply #6 on: March 21, 2019, 01:09:47 AM »
I dont need that stuff. Scripts injections can be various in templates.
Do you know how to override functions in /core/engine/controller.php?
« Last Edit: March 21, 2019, 01:10:26 AM by Basara »

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: extend or hook
« Reply #7 on: March 21, 2019, 07:49:58 AM »
Yes, i know. You cannot to override function of AController. It's a core base abstract controller. 
You should to manipulate your js and css via tpl-replacements, pre- and post- tpls of your extension,
or effect on ADocument class from your hooks ($this->document->addScript(); ). 
Not sure that approach with disabling some js files from extension is good. Extension is one of many and can conflict with other
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline natdroid

  • Full Member
  • ***
  • Posts: 113
  • Karma: +36/-3
    • View Profile
Re: extend or hook
« Reply #8 on: March 21, 2019, 08:00:18 AM »
thank you

 

Powered by SMFPacks Social Login Mod