Skip to content
This repository

Saved content HTML stores <img ...> instead of {{ plugin_object }} #1130

spookylukey opened this Issue · 3 comments

4 participants

Luke Plant Jonas Obrist Daniele Procida Patrick Lauber
Luke Plant

The way that the admin for text plugins used to work (probably back in django-cms 1.0 days, I can't trace it all the way), was like this:

  1. the admin would display <img> tags to represent embedded plugins.
  2. when saved, these would be converted to things like {{ plugin_object 123 }}
  3. when rendered, these would be converted to the rendered output of the plugin object.

I know this, because I designed it, and it is described here:!msg/django-cms/Q4L5m408U6I/-BtSqAReSTIJ

Unfortunately, for some reason step 2 has been removed, and step 3 modified to cope, I think mistakenly: 8ef9832#L12L50

So now the database is storing obscure <img> tags to represent plugins, making it harder to understand and more fragile (e.g. if some other editor is used to edit the HTML, which doesn't preserve the 'id' attribute on the <img> tags, or if you want to export your data).

Fixing this would be tricky - we would need a datamigration to fix all up the this stuff, which could take a while to run.

We would also need to change the way that the admin saves the HTML, so that plugin_admin_html_to_tags is actually used. I haven't looked into doing this yet, but should just be a matter of appropriate code in the ModelAdmin.save_model()

The alternative is to just live with it, and fix the code accordingly. Currently there is a whole bunch of confusing cruft in cms/plugins/text/ and some in cms/plugins/text/

(I'm happy to do either of these., BTW).

Jonas Obrist

I agree that the text plugin does weird magic. And I agree we need to fix this.

It seems that this could be somewhat related to the ever-recurring discussion about displaying plugins with something else than images in the admin. An idea I had once (and have no idea whether it's feasible or not) is to have a <cmsplugin id=141 /> tag instead of obscure image tags to identify cmsplugin positions. Then either have custom content (images or whatever) embedded inside that tag or somehow do that via javascript.

Daniele Procida

The big advantage that images in the admin provide is draggability. In every other respect, they are poor - they are hacky and weird and make the source in the editor unpleasant to look at.

Also, some users seem to manage to turn them into content in the editor somehow.

But, I don't know what would be a good alternative.

As for storage in the database, storing them as renderable templatetags would be more elegant and presumably slightly faster too.

Patrick Lauber digi604 closed this
Patrick Lauber

closing as all text plugins have been removed from core.

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.