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

Plugins within Text render twice! #34

Closed
DrMeers opened this issue May 13, 2009 · 1 comment
Closed

Plugins within Text render twice! #34

DrMeers opened this issue May 13, 2009 · 1 comment

Comments

@DrMeers
Copy link
Contributor

DrMeers commented May 13, 2009

Placeholder seems to merrily iterate through all plugins whilst rendering without checking whether some of them are actually embedded within others! For efficiency, it would probably be best to add an 'embedded' or 'nested' boolean field to the CMSPlugin class which can be set upon creation, however for now I have implemented a quick hack to get around it on my system:

diff --git a/cms/templatetags/cms_tags.py b/cms/templatetags/cms_tags.py
index afc34e2..22d2281 100644
--- a/cms/templatetags/cms_tags.py
+++ b/cms/templatetags/cms_tags.py
@@ -387,7 +387,18 @@ class PlaceholderNode(template.Node):
         else:
             plugins = CMSPlugin.objects.filter(page=page, language=l, placehold
             c = ""
+
+            nested_ids = []
+            from cms.plugins.text.utils import OBJ_ADMIN_RE
+            for plugin in plugins:
+                i = plugin.get_plugin_instance()[0]
+                if getattr(i, 'body', False):
+                    for m in OBJ_ADMIN_RE.findall(i.body):
+                        nested_ids.append(int(m))
+                        
             for plugin in plugins:
+                # check that it's not already nested
+                if plugin.id in nested_ids: continue
                 c += plugin.render_plugin(context, self.name)
         if not c:
             return ''
@digi604
Copy link
Contributor

digi604 commented May 13, 2009

should work again.... you can actually filter if the plugin has a parent or not. because plugins will be organized in a tree soon, mptt for them is already in place and used for the text plugin.

vxsx added a commit that referenced this issue Jul 10, 2015
This issue was closed.
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

2 participants