Keyword

Set ID on UL tag in K2 tools module (Categories List Menu)

  • Jennie Dawson
  • Jennie Dawson's Avatar Topic Author
  • Offline
  • Junior Member
More
4 years 1 month ago #174738 by Jennie Dawson
Hi,

I have a categories list (Menu) module set up with K2 Tools and I need to set an ID on the UL tag so I can get my responsive menu to work.

In the Joomla menu modules it is in the Advanced settings, but this is not available in the K2 module.

I have looked through the settings and can't find an option for this, and I've also looked for a template file to use in overrides but so far have drawn a blank.

Can someone point me in the right direction please?

Many thanks
Jennie

Please Log in or Create an account to join the conversation.

More
4 years 1 month ago #174744 by JoomlaWorks
Actually, an ID is auto-generated for all K2 modules. In your case, it's this: github.com/getk2/k2/blob/master/modules/mod_k2_tools/tmpl/categories.php#L15

You can either use that generated ID, or simply make an override for the category listing inside your Joomla template and change the HTML wrappers as you want.

More on K2 and overrides here: getk2.org/documentation/tutorials/templating-with-k2-and-the-concepts-of-sub-templates

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Jennie Dawson
  • Jennie Dawson's Avatar Topic Author
  • Offline
  • Junior Member
More
4 years 1 month ago #174754 by Jennie Dawson
Hi Fotis
I had looked at this file but the UL tag is not being generated by the PHP code in categories.php.
I need to set the ID on the UL tag, which is referenced in the following JS code in my template:

<script>var menu1 = $('#menu');
var menu2 = $('#leftnav');

menu1.slicknav({
prependTo: '#first',
label: 'Main Menu'
});

menu2.slicknav({
prependTo: '#second',
label: ''
});
</script>

Thanks, Jennie

Please Log in or Create an account to join the conversation.

More
4 years 1 month ago #174772 by JoomlaWorks
There is no need to modify the <ul> element. Simply adapt your JS code's selector, e.g. change $('#menu') to $('#k2ModuleBoxXYZ ul') where "k2ModuleBoxXYZ" is the ID generated by the K2 module.

These selectors work like CSS selectors so they are easy to manipulate.

If on the other hand this is not possible to alter on your side, e.g. it's hardcoded on the template, you'll have to consult your template provider.

The reason you can't directly change the ul element in the categories menu is because it's part of the generated structure and cannot easily be overridden in a template.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Jennie Dawson
  • Jennie Dawson's Avatar Topic Author
  • Offline
  • Junior Member
More
4 years 1 month ago #174778 by Jennie Dawson
Thank you Fotis, that works brilliantly for me now!
x

Please Log in or Create an account to join the conversation.

More
4 years 1 month ago #174791 by JoomlaWorks
Great :)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum