Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

  • 0
Séane

How to override BlockTopMenu

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

 

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 1

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.
 

Share this post


Link to post
Share on other sites
  • 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

Share this post


Link to post
Share on other sites
  • 0

You needto do it in yourtheme/modules/blocktopmenu/blocktopmenu.tpl

Edited by tommat

Share this post


Link to post
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?

 

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
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

Share this post


Link to post
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

×