When displaying nested lists, they are created like this:

<ul>
<li class="expanded"><a href="/taxonomy/term/3">Internet Services</a></li>
<ul>
<li class="collapsed"><a href="/taxonomy/term/1">Web Sites</a></li>
</ul>
</ul>
...

HOWEVER, they should be created like this:

<ul>
<li class="expanded"><a href="/taxonomy/term/3">Internet Services</a>
<ul>
<li class="collapsed"><a href="/taxonomy/term/1">Web Sites</a></li>
</ul>
</li>
</ul>
...

Specifically, you cannot nest a UL directly within another UL. It MUST be contained within an

  • first.
  • CommentFileSizeAuthor
    #5 sitemenu.module8.81 KBMéléis

    Comments

    kbahey’s picture

    Do you have a reference from W3C or elsewhere that it should be the way you mentioned?

    Before fixing it, I just want to make sure that this is in conformance to standards.

    Thanks.

    tangent’s picture

    The W3C definition for lists states that the ONLY element that may be placed in a UL element is an LI element. This isn't stated very clearly though and you must look at the DTD to determine this.

    <!ELEMENT UL - - (LI)+                 -- unordered list -->
    

    http://www.w3.org/TR/REC-html40/struct/lists.html#edef-UL

    You can also validate the page output using the HTML validator.

    http://validator.w3.org/

    kbahey’s picture

    Yeah, I see the problem now. However with the code as it is now, it is hard to modify it.

    Patches welcome though.

    moshe weitzman’s picture

    i don't know if the dhtml script which powers taxonomy_dhtml understands the desired nesting. I remember struggling with this before.

    Méléis’s picture

    Version: » master
    Status: Active » Needs review
    StatusFileSize
    new8.81 KB

    Here is the diff i've just done :

    227a228
    >       $output .= '</li>'."\n";
    247c248
    <       $output .= "<li class=\"expanded\">". $link ."</li>\n";
    ---
    >       $output .= "<li class=\"expanded\">". $link ."\n";
    254c255,257
    <   $output .= str_repeat("</ul>\n", 1+$term->depth);
    ---
    >   if ($term->depth >= 1) { $output .= '</ul></li>'."\n"; }
    >   if ($term->depth == 0) { $output .= '</ul>'."\n"; }
    >   $output .= str_repeat("</ul>\n", $term->depth);
    

    The patch works for me but i've got a quite simple list to generate. There is just one level... so i haven't tested it on other ones. You can see a working version here : http://www.meleis.yi.org/plan-du-site/.

    It's not a perfect patch i've just done something that works. I have to admit i really don't care about PHP code as long as HTML code is clean.

    As it is a theme_sitemenu_render_outline($tree) if you are using PHP based themes you can create a function named nameofyourtheme_sitemenu_render_outline($tree) without having to change the original file.

    Complete file is attached to this post.

    Have fun :o).

    Méléis’s picture

    I've forgotten to say : if you have an empty taxonomy it generates an only "

    ". So of course it's not valid.

    If you want my opinion the loop mustn't be done while there is nothing to show (you have to test it before launching the loop).

    Anyway it's not a problem at all because an empty list is just useless. You can desactivate the empty taxonomy in sitemenu properties and you can also fill it :o).

    Méléis’s picture

    Sorry : "I've forgotten to say : if you have an empty taxonomy it generates an only </ul>. So of course it's not valid."

    kbahey’s picture

    Assigned: Unassigned » kbahey
    Status: Needs review » Fixed

    Thanks to Meleis for the fix. It is now commited.

    Anonymous’s picture

    Anonymous’s picture

    Status: Fixed » Closed (fixed)