Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated side menu creates invalid html ul list #2

Open
JakubJecminek opened this issue Apr 23, 2013 · 1 comment
Open

Generated side menu creates invalid html ul list #2

JakubJecminek opened this issue Apr 23, 2013 · 1 comment

Comments

@JakubJecminek
Copy link

https://github.com/alkacon/modules-v8/blob/branch_8_5_x/modules/com.alkacon.opencms.v8.template3/resources/system/modules/com.alkacon.opencms.v8.template3/elements/menu/nav_side.jsp

from demo template 3 example of the problem:

   <li><a href="/flower-en/flower-search/solr-integration/" >Flower Search</a>    
    </li>   
   <li><a href="/flower-en/flower-subscription/" >Flower Subscription</a>  
  </li></ul></li></ul>
  </li>
 </ul>

As you can see on the end of the ul list thare are redundant html tags. This issue is still valid for 8.5.1.

@JakubJecminek
Copy link
Author

I did some experiments with nav_side.jsp both on demo flower site and our other projects and I think I've found a solution for this problem. After my change in nav_side.jsp the previous html snippet looks like this

<li><a href="/opencms/opencms/flower-en/flower-search/solr-integration/" >Flower Search</a>             
                </li>           
<li><a href="/opencms/opencms/flower-en/flower-subscription/" >Flower Subscription</a>      
</li></ul>  

which is valid html ul list. I test it with several different pages many items in navigation and it still produce valid html list. Here is changed nav_side.jsp:

<%@page buffer="none" session="false" taglibs="c,cms,fn" %>
<c:set var="navStartLevel" ><cms:property name="NavStartLevel" file="search" default="0" /></c:set>
<cms:navigation type="treeForFolder" startLevel="${navStartLevel + 1}" endLevel="${navStartLevel + 3}" var="nav"/>
<div id="nav_left">
    <ul>            
        <c:set var="oldLevel" value="" />
        <c:forEach items="${nav.items}" var="elem">
            <c:set var="currentLevel" value="${elem.navTreeLevel}" />
            <c:choose>
                <c:when test="${empty oldLevel}"></c:when>
                <c:when test="${currentLevel > oldLevel}"><ul></c:when>
                <c:when test="${currentLevel == oldLevel}"></li></c:when>
                <c:when test="${oldLevel > currentLevel}">
                    <c:forEach begin="${currentLevel + 1}" end="${oldLevel}"></li></ul></c:forEach></li>
                </c:when>
            </c:choose>

            <li><a href="<cms:link>${elem.resourceName}</cms:link>" <c:if test="${!elem.navigationLevel && nav.isActive[elem.resourceName]}">class="current"</c:if>>${elem.navText}</a>

            <c:set var="oldLevel" value="${currentLevel}" />
        </c:forEach>

        <c:forEach begin="${navStartLevel+1}" end="${oldLevel}"></li></ul></c:forEach>  
</div>

I could create pull request if you find this change valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant