Séane Posted February 5, 2019 Posted February 5, 2019 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
1 tommat Posted February 5, 2019 Posted February 5, 2019 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 datakick Posted February 6, 2019 Posted February 6, 2019 @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 } } 1
0 tommat Posted February 5, 2019 Posted February 5, 2019 (edited) You needto do it in yourtheme/modules/blocktopmenu/blocktopmenu.tpl Edited February 5, 2019 by tommat
0 Séane Posted February 5, 2019 Author Posted February 5, 2019 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 Séane Posted February 7, 2019 Author Posted February 7, 2019 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 Séane Posted February 7, 2019 Author Posted February 7, 2019 (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 February 7, 2019 by Séane
0 wakabayashi Posted February 7, 2019 Posted February 7, 2019 @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 Séane Posted February 7, 2019 Author Posted February 7, 2019 (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 February 7, 2019 by Séane
Question
Séane
Hello,
I am trying to everride the blocktopmenu module without touching the code .php file.
The class is
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
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 accountSign in
Already have an account? Sign in here.
Sign In Now