Page 1 of 1

[solved] Menu Manager - ID assignment?

Posted: Tue Jun 16, 2015 8:00 pm
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.

Re: Menu Manager - ID assignment?

Posted: Tue Jun 16, 2015 8:04 pm
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...

Re: Menu Manager - ID assignment?

Posted: Tue Jun 16, 2015 8:11 pm
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?

Re: Menu Manager - ID assignment?

Posted: Tue Jun 16, 2015 8:28 pm
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...

Re: Menu Manager - ID assignment?

Posted: Tue Jun 16, 2015 8:41 pm
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.

Re: Menu Manager - ID assignment?

Posted: Tue Jun 16, 2015 8:57 pm
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

Re: [solved] Menu Manager - ID assignment?

Posted: Tue Jun 16, 2015 9:00 pm
by rbaby
Thank you again, I will look into it. Appreciate your time.