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

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

Closed
spookylukey opened this issue Jan 2, 2012 · 3 comments
Closed
Milestone

Comments

@spookylukey
Copy link
Contributor

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: https://groups.google.com/forum/#!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/utils.py and some in cms/plugins/text/models.py

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

@ojii
Copy link
Contributor

ojii commented Jan 18, 2012

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.

@evildmp
Copy link
Contributor

evildmp commented Jun 15, 2012

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.

@digi604
Copy link
Contributor

digi604 commented Jul 11, 2013

closing as all text plugins have been removed from core.

@digi604 digi604 closed this as completed Jul 11, 2013
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

4 participants