3

I'm trying to understand how to override the helper.php found in /joomla_site/modules/mod_k2_tools because it is not a component but a module, and it is not the controller, because the controller is mod_k2_tools.php.

If that above is right, then I have no idea how to override the helper.php to change the functionily of the K2 calendar.

I read How to override core classes, and followed the example How to override the component mvc from the Joomla! core. However, nothing changed.

Before started with the override, I directly modified the /joomla_site/modules/mod_k2_tools/helper.php to get the functionality I was looking for and as it worked, I decided starting with the override issue.

In the plugin that we must create, in the line

if('com_content' == JRequest::getCMD('option') && !$app->isAdmin())

the com_content makes reference to the content component, so, it should be replace by the 'mod_k2_tools` string, right?

Can the helper.php be overridden? Any guidance on what to check or pointing to a new beginning?

I'm using Joomla! 2.5.27, and K2 2.6.8.

3

Firstly, not everything can be overriden, sometimes you can just create your own mod_myk2_tools.

Secondly, a feature can be overriden only if it is instantiated with a dynamic loading mechanism. This kind of technique checks if a resourse is already loaded before loading, allowing to load it before. In mod_k2_tools module, the helper is just included in this basic PHP way: "require_once (dirname(FILE).DS.'helper.php');". It is not possible to override it.

  • In the case of create the own mod_myk2_tools module, it is necessary change the name of the classes? – pQB Oct 18 '14 at 14:32
  • It seems it's not necessary. It works as you described. Now I can override the corresponding functionality. – pQB Oct 18 '14 at 15:11
  • 1
    If you create a new module, it is better to avoid name conflicts. Two classes with the same name cause a Fatal PHP Error. – Anibal Oct 19 '14 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.