Jump to content
thirty bees forum
  • 0

How to override BlockTopMenu


Question

Posted

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

 

8 answers to this question

Recommended Posts

  • 1
Posted

Sorry, i forgot how that module was made and i was not at comp at the time of writing a reply.

One option is to add class with jquery.
 

  • 1
Posted

@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
  • 0
Posted

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?

 

  • 0
Posted

Hello,

It does not seem to work on my side. I've cleared the cache, just in case, but so far no luck.

Could you please indicate it the 'overrides' folder should be at the root of the theme, or elsewhere?

 

Séane

  • 0
Posted (edited)

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
  • 0
Posted

@Séane Well IMO its kind of logical to ovveride only tpl files in a theme. For me the problem in this case is the module itself. It codes the html stuff in the php file. Normally only beginner code like this :S I am not sure, if there is specific reason to do it.

  • 0
Posted (edited)

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

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...