Keyword

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

  • Jennie Dawson
  • Jennie Dawson's Avatar Topic Author
  • Offline
  • New Member
More
1 week 6 days ago #174738 by Jennie Dawson
Jennie Dawson created the topic: Set ID on UL tag in K2 tools module (Categories List Menu)
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.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 week 5 days ago #174744 by Fotis
Fotis replied the topic: Set ID on UL tag in K2 tools module (Categories List Menu)
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

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Jennie Dawson
  • Jennie Dawson's Avatar Topic Author
  • Offline
  • New Member
More
1 week 3 days ago #174754 by Jennie Dawson
Jennie Dawson replied the topic: Set ID on UL tag in K2 tools module (Categories List Menu)
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.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 week 2 days ago #174772 by Fotis
Fotis replied the topic: Set ID on UL tag in K2 tools module (Categories List Menu)
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.

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Jennie Dawson
  • Jennie Dawson's Avatar Topic Author
  • Offline
  • New Member
More
1 week 2 days ago #174778 by Jennie Dawson
Jennie Dawson replied the topic: Set ID on UL tag in K2 tools module (Categories List Menu)
Thank you Fotis, that works brilliantly for me now!
x

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

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 week 2 days ago #174791 by Fotis
Fotis replied the topic: Set ID on UL tag in K2 tools module (Categories List Menu)
Great :)

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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


Powered by Kunena Forum