Jump to content
thirty bees forum
  • 0

How to override BlockTopMenu


Séane

Question

Hello,

I am trying to everride the blocktopmenu module without touching the code .php file.

The class is 

generateCategoriesMenu

is protected, which should allow to modify it from the theme.

 

What I am trying to do is basically to add a class="parent" to <li> for parent categories.

 

Would there be a specific way with ThirtyBees?

Kind regards,
Séane

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 1

@Séane it's possible to override module's primary file, so you are in luck. Just create file overrides/modules/blocktopmenu/blocktopmenu.php with content like this:

class BlocktopmenuOverride extends Blocktopmenu
{
 	protected function generateCategoriesMenu($categories, $isChildren = 0)
    {
		// your custom implementation
	}
}

 

  • Like 1
Link to comment
Share on other sites

  • 0

Hello,

Actually, I don't want to update the .tpl as you can't do anything inside.

The only code there is is: 

{if $MENU != ''}
<div id="blocktopmenu-tpl">
<nav>
<ul>
{$MENU}
</ul>
</nav>
</div>
{/if}

 

 

What I would like to do is to amend the html and add specific class, such as a class for all the parent <li>.

 

This can only be done in the .php but the class is private.

 

Any guess?

 

Link to comment
Share on other sites

  • 0

Hi,
My bad.
I actually figured out:
The override folder is at the root of Thirty Bees.

But then, this is not exactly what I would like to do, since I would like the override to happen from the theme folder.

Basically, I would like the user to download the theme and install the theme, and the override would work straight away without any change of the core/root folder.
I guess I will need to use javascript as mentioned in a previous comment.
I find it odd we can override modules .tpl in the theme folder but not the .php files.

Thank you for your help,
Séane

Edited by Séane
Link to comment
Share on other sites

  • 0

Well,
I am more of a designer than a programmer, so I could not judge. I am tweaking the code as much as I can.

But this is frustrating.
Even trying to bypass this with Javascript seems to be difficult as you need to add a class to the module and create a hook in the header. You can't really load a .js file from the .tpl.

I might end up changing the core code after all.

Séane

Edit: actually loading a .js from the .tpl was quite easy:
 

<script type="text/javascript" src="{$tpl_uri}modules/blocktopmenu/blocktopmenu.js"></script>
Edited by Séane
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...