Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

render_model templatetag should create unique classnames #2822

Closed
stefanfoulis opened this Issue · 4 comments

4 participants

Stefan Foulis Angelo Dini Iacopo Spalletti Patrick Lauber
Stefan Foulis
Owner

The {% render_model post "myfield" "myfield" "" safe %} templatetag generates a class on the wrapping div that is used in JS (<div class="cms_plugin cms_plugin-myapp-mymodel-myfield-2 cms_render_model"><p>asdfadsf</p></div>).

If the same model is used multiple times on the same page (e.g a list of blog posts and another list of the same blog post in a "latest posts" plugin in the sidebar). The same class (cms_plugin-myapp-mymodel-myfield-2) is used twice on the same page.

The current effect is that the window openen on doubleclick is not positioned correctly. But it might have other issues as well.

blog-post-placeholder-edit-window wrong-position

Patrick Lauber digi604 added this to the 3.0 milestone
Patrick Lauber digi604 added the blocker label
Angelo Dini
Owner

@yakky maybe you might have a quick solution?

Iacopo Spalletti
Collaborator

Quick and dirty solution, which will require to rework tests a bit, is to add a randomization here https://github.com/divio/django-cms/blob/develop/cms/templates/cms/toolbar/plugin.html#L5 and https://github.com/divio/django-cms/blob/develop/cms/templates/cms/toolbar/plugin.html#L12 in the cms-plugin-whatever DOM class.
The class name is built to be unique per instance but totally deterministic.
Or, we can add a mode parameter to the render_model templatetag and use it in the DOM class name; in this case, it's up to the user to pass the correct mode for every use; something like:

{% render_model post 'abstract' '' '' '' 'main' %}

vs:

{% render_model post 'abstract' '' '' '' 'plugin' %}
Patrick Lauber
Collaborator

but isn't this just some JS problem?

Iacopo Spalletti
Collaborator

There are two failing assumptions in this bug:

  1. Every frontend-enabled DOM element shalt be unique per page
  2. Every frontend-enabled model instance shalt be unique per page

I don't know if @FinalAngel can overcome the first one in the javascript, I can try to patch the second one in the plugin.html template

Angelo Dini FinalAngel referenced this issue from a commit in FinalAngel/django-cms
Angelo Dini FinalAngel fixes issue #2822 208afee
Patrick Lauber digi604 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.