[Answer]-Displaying django-cms submenu in an option element


Thanks for your reply. I’ve actually managed to do it using some JS. I’ve converted the <li> tags to <option> here is the code:

<script type="text/javascript">
                $('.subnav').each(function() {
                    $(this).find('a').each(function() {
                            var $option = $('<option />');
                            $option.attr('value', $(this).attr('href')).html($(this).html());
                    window.location.href = $(this).val();

I will try your solution now as it’s much cleaner, but the code above could be handy for someone else in the future.

Thanks again!


As you said yourself, the documentation tells you to use a custom template, which is exactly what you should do in this case.

    {% show_sub_menu 1 "option_menu.html" %}

Then in “option_menu.html”:

{% for child in children %}
    <option>{{ child.get_menu_title }}</option>
{% endfor %}

Note this will only show one level of sub-menu, for more, check {% if child.children %} and if it is True, do what you think is best in your case.


Leave a comment