Override BaseMenu function, one module only.

I have modzzz Advanced Articles installed on 7.2.
I would like to override and change the format of one of the page elements.
The function responsible for producing the text I want to format differently is defined in BxBaseMenu (line 381):

   function genSubHeader(

...and specifically the variable $sCaptionWL:

$sCaptionWL = $this->sCustomSubHeader != '' ? $this->sCustomSubHeader : $this->genSubHeaderCaption($this->aTopMenu[$iFirstID], $sCaption);

...this variable is replaced in the templates/templ_evo/navigation_menu_sub_header.html:

<div class="sys_page_header bx-def-padding-right">__caption__<bx_injection:injection_title_zone /></div>

...which I have over-ridden by copying the file to modules/modzzz/articles/templates/navigation_menu_sub_header.html

It seems the best way to achieve this is to extend the BxBaseMenu class and then redeclare the genSubHeader with the changes I want to make, but I cannot seem to extend the BxBaseMenu class. After looking closely at the directory and file structure, it seems that only templates themselves override BxBaseMenu.
I have tried to add a scripts folder to the module and extend BxBaseMenu in there, with no success.

What is the best way to proceed, does anybody have to time and knowledge to point me in the right direction?
Thanks :)

Quote · 11 Jan 2016

BxBase* classes can be overridden in BxTempl* classes.

So you need to modify templates/tmpl_{custom_template_name}/scripts/BxTemplMenu.php file.

Rules → http://www.boonex.com/terms
Quote · 16 Jan 2016

Thanks for the reply Alex.
I had achieved it the way you advised in the end:

$sCaptionWL = $this->sCustomSubHeader != '' ? $this->sCustomSubHeader : $this->genSubHeaderCaption($this->aTopMenu[$iFirstID], $sCaption);   
        //HACK [if we are viewing article page, reformat the date -  12/1/16]
        if ( strpos($_SERVER['QUERY_STRING'], 'articles')  && strpos($_SERVER['QUERY_STRING'], 'view') ){
            $sDate = new DateTime(substr($sCaptionWL,0,10));
            $sCaptionWL = $sDate->format('D jS M Y');
        }
        //END HACK

However, this change would be lost if the user changes template, and I was trying to make a change that would be contained within the module itself, so that it affected all templates, but not all modules.

Quote · 16 Jan 2016

Post this question in the support forum for that module.  Modzzz is great at answering questions his customers may have.

Geeks, making the world a better place
Quote · 16 Jan 2016

You could do it in BxBase* class but your modification maybe overwritten during upgrade, so it's better to this in BxTempl* files in all templates. You can make this modification in one template and include the file in other templates, since class name is the same it should work.

However, this change would be lost if the user changes template, and I was trying to make a change that would be contained within the module itself, so that it affected all templates, but not all modules.

 

Rules → http://www.boonex.com/terms
Quote · 18 Jan 2016
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.