[solved] Menu Manager - ID assignment?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
rbaby
Forum Members
Forum Members
Posts: 144
Joined: Thu Feb 07, 2008 10:28 pm

[solved] Menu Manager - ID assignment?

Post by rbaby »

I'm doing an accordion-style menu but the format requires the main to have an ID, and the sub-items have the same ID to make the association.

Any ideas on how I can populate each menu item and sub-menu to have its own unique ID?

Code: Select all

<ul>
<li id="ID">Main Navigation
     <ul id="ID">
          <li>Sub-Item</li>
     </ul>
</li>
<li id="ID2">Main Navigation
     <ul id="ID2">
          <li>Sub-Item</li>
     </ul>
</li>
</ul>
Thanks in advance.
Last edited by rbaby on Tue Jun 16, 2015 8:59 pm, edited 2 times in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Menu Manager - ID assignment?

Post by Jo Morg »

rbaby wrote:I'm doing an accordion-style menu but the format requires the main to have an ID, and the sub-items have the same ID to make the association.
An id should be unique within a page, so the id selector is used if you want to select a single, unique element. It's better to use the class which is much more flexible. You can even have multiple classes for the same element...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
rbaby
Forum Members
Forum Members
Posts: 144
Joined: Thu Feb 07, 2008 10:28 pm

Re: Menu Manager - ID assignment?

Post by rbaby »

Jo Morg wrote:
rbaby wrote:I'm doing an accordion-style menu but the format requires the main to have an ID, and the sub-items have the same ID to make the association.
An id should be unique within a page, so the id selector is used if you want to select a single, unique element. It's better to use the class which is much more flexible. You can even have multiple classes for the same element...
Thank you Jo Morg but the idea is that it should be unique per page. It's what determines which child belongs to which parent to expand on the accordion. Is there a way to print the page ID and then the child print the parent page ID?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Menu Manager - ID assignment?

Post by Jo Morg »

rbaby wrote:

Code: Select all

<ul>
<li id="ID">Main Navigation
     <ul id="ID">
          <li>Sub-Item</li>
     </ul>
</li>
<li id="ID2">Main Navigation
     <ul id="ID2">
          <li>Sub-Item</li>
     </ul>
</li>
</ul>
This won't render as valid HTML... and this is your example.
rbaby wrote:Thank you Jo Morg but the idea is that it should be unique per page
That is where one of us is misinterpreting the other....
Being unique per page and being unique within a page are different things... and two elements on the same page cannot have the same id. Other than that you should be able to get any database unique id for a any of the nodes by using the

Code: Select all

{$node->id}
as it is documented on the module's help page...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
rbaby
Forum Members
Forum Members
Posts: 144
Joined: Thu Feb 07, 2008 10:28 pm

Re: Menu Manager - ID assignment?

Post by rbaby »

Jo Morg wrote:
rbaby wrote:

Code: Select all

<ul>
<li id="ID">Main Navigation
     <ul id="ID">
          <li>Sub-Item</li>
     </ul>
</li>
<li id="ID2">Main Navigation
     <ul id="ID2">
          <li>Sub-Item</li>
     </ul>
</li>
</ul>
This won't render as valid HTML... and this is your example.
rbaby wrote:Thank you Jo Morg but the idea is that it should be unique per page
That is where one of us is misinterpreting the other....
Being unique per page and being unique within a page are different things... and two elements on the same page cannot have the same id. Other than that you should be able to get any database unique id for a any of the nodes by using the

Code: Select all

{$node->id}
as it is documented on the module's help page...
Oh yes, you're absolutely right, sorry I missed it:

Code: Select all

<ul>
<li><a href="#id">Main Navigation</a>
     <ul id="ID">
          <li>Sub-Item</li>
     </ul>
</li>
<li><a href="#id2">Main Navigation</a>
     <ul id="ID2">
          <li>Sub-Item</li>
     </ul>
</li>
</ul>
Is how it's suppose to be. I will try the node ID but I wasn't sure if it would print the same ID for each main/sub. Thank you Jo Morg.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Menu Manager - ID assignment?

Post by Jo Morg »

rbaby wrote:I will try the node ID but I wasn't sure if it would print the same ID for each main/sub.
If you have the CGSimpleSmarty module it should be relatively simple to get the parent's id (look into the module's help), otherwise you'll need to research a bit the CMSMS API, but in any case it should be possible. I'm even almost sure that it has been asked and answered already on this forum. :P
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
rbaby
Forum Members
Forum Members
Posts: 144
Joined: Thu Feb 07, 2008 10:28 pm

Re: [solved] Menu Manager - ID assignment?

Post by rbaby »

Thank you again, I will look into it. Appreciate your time.
Post Reply

Return to “Modules/Add-Ons”