Skip to content
View in the app

A better way to browse. Learn more.

thirty bees forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to override BlockTopMenu

Featured Replies

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

 

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

Edited by tommat

  • Author

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?

 

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.
 

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

 

  • Author

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

  • Author

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

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

  • Author

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.