Question

Lets say I have created a facebook like box plugin in django cms, it allows the user to put in page urls and other configuration to display the facebook like box.

Now the user wants to display the same like box across multiple pages, is it possible to reuse the same plugin instance without creating the plugins on every page?

class FacebookLikeBox(CMSPlugin):
    page_url = models.URLField()
    app_id = models.CharField(max_length=25)
    width = models.CharField(max_length=25)
    height = models.CharField(max_length=25)
    color_scheme = models.CharField(max_length=25, choices=(('light','light'),('dark','dark')))
    show_friends_faces = models.BooleanField(default=True)
    show_posts = models.BooleanField(default=True)
    show_header = models.BooleanField(default=True)
    show_border = models.BooleanField(default=True)
Was it helpful?

Solution

You have two options (maybe more).

If you are using django-cms < 3.x then you can install djangocms-stacks which is a cool application that allows you to create reusable "stacks" of plugins that can be managed from the admin just like a placeholder.

The the stack will render all it's plugin whenever it encounters the {% stack "yourstackname" %} in a template.

In django-cms >= 3.x this package was moved to the cms core so no need to install it.

The second option is using the {% show_placeholder %} template tag. You can read more about this tag here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top