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

Unexpected behaviour rendering template recursive #6603

Open
Hero9909 opened this Issue Jan 25, 2019 · 2 comments

Comments

Projects
None yet
1 participant
@Hero9909
Copy link

Hero9909 commented Jan 25, 2019

Summary

I have created an simple cms plugin with an simple model and a few properties, the plugin renders into an navigation bar and a second one into its navigation items. The navigation items can either be an menu or an simple link. To achieve this i've defined a propety : type. So as expected in the template is an if clause with the elements to render, but if the template gets rendered , the child plugins of any menu switching their position. This does work properly if i change the links to comments. See examples at expected and actual behaviour. sadly there are no errors thrown / shown

Expected behaviour

template menu

{% if type == 0 %}
<div class="menu">
    <a class="item-link">
        <span class="item-head">{{ instance.title }}</span>
        <div class="dropdown">
            {% for plugin in instance.child_plugin_instances %}
                {% render_plugin plugin %}
            {% endfor %}
        </div>
    </a>
</div>
{% else %}
<a class="menu-link">{{ instance.title }}</a>
{% endif %}

Plugins:
Navbar

  • menu(type:0)
    • menu(type:1)

Browser

<div class="menu">
    <a class="item-link">
        <span class="item-head">Titel</span>
        <div class="dropdown">
            <a class="menu-link">Item</a>
        </div>
    </a>
</div>

Actual behaviour

Original

template menu

{% if type == 0 %}
<div class="menu">
    <a class="item-link">
        <span class="item-head">{{ instance.title }}</span>
        <div class="dropdown">
            {% for plugin in instance.child_plugin_instances %}
                {% render_plugin plugin %}
            {% endfor %}
        </div>
    </a>
</div>
{% else %}
<a class="menu-link">{{ instance.title }}</a>
{% endif %}

Browser

<div class="menu">
    <a class="item-link">
        <span class="item-head">Titel</span>
    </a>
    <div class="dropdown">
        <a class="menu-link">Item</a>
    </div>
</div>

first try

template menu

{% if type == 0 %}
<div class="menu">
    <a class="item-link">
        <div class="dropdown">
            {% for plugin in instance.child_plugin_instances %}
                {% render_plugin plugin %}
            {% endfor %}
        </div>
        <span class="item-head">{{ instance.title }}</span>
    </a>
</div>
{% else %}
<a class="menu-link">{{ instance.title }}</a>
{% endif %}

Browser

<div class="menu">
    <a class="item-link">
    </a>
    <div class="dropdown">
        <a class="menu-link">Item</a>
    </div>
    <span class="item-head">Titel</span>
</div>

second thought

template menu

{% if type == 0 %}
<div class="menu">
    <a class="item-link">
        <span class="item-head">{{ instance.title }}</span>
        <div class="dropdown">
            {% for plugin in instance.child_plugin_instances %}
                {% render_plugin plugin %}
            {% endfor %}
        </div>
    </a>
</div>
{% else %}
<!--a class="menu-link">{{ instance.title }}</a-->
{% endif %}

Browser

<div class="menu">
    <a class="item-link">
        <span class="item-head">Titel</span>
       <div class="dropdown">
            <!--a class="menu-link">Item</a-->
        </div>
    </a>
</div>

Environment

  • Python version: 3.7
  • Django version: 1.11.17
  • django CMS version: 3.5.3
@Hero9909

This comment has been minimized.

Copy link
Author

Hero9909 commented Jan 25, 2019

just to make shure ive tried to extract the link into an seperate template / model / plugin. doesnt changed behaviour at all.

@Hero9909

This comment has been minimized.

Copy link
Author

Hero9909 commented Jan 31, 2019

Figured out that the problem is the <a> inside the <a> , changing outer tag to something like <span> and the code works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment