Is it possible to nest plugins in django-cms 2? - django

I am trying to have nested plugins in Django-CMS, i.e. a plugin template which itself
contains placeholder tags which can be filled with content.
I tried the straightforward way of just putting the tags there and I can add content
via frontend editing, but when I save it, it never shows up.
Am I doing something wrong or is it just not supported?
I am using Django-CMS 2.4.3
Thanks in advance!

You actually have to 'render' the child plugins in the plugin template.
I am not sure if {% render_plugin %} is already inplemented in 2.4.... For best experience with nested plugins be sure to upgrade to 3.0

Related

Replace Javascript with Bootstrap responsive slideshow

I'm trying to find a nice looking bootstrap slideshow that looks similar to this one: https://www.jssor.com/demos/simple-fade-slideshow.slider
I would use the one in the link but it's got way to much Javascript and doesn't respond properly when I change the size of my window. Any ideas how I could create this using Bootstrap, HTML and CSS only? So it still needs to be automatic as well.
Thank you
It’s the carousel you’re after, without knowing which version of bootstrap you’re on I cannot provide an example but you can find full examples for what you need in the bootstrap docs: https://getbootstrap.com/docs/4.1/components/carousel/

Ember.js: How do you load model into addon hbs template?

Maybe I just don't know the correct terminology or something but I can't figure out how to do this. Ember is pretty new to me, and it's pretty lacking in documentation it seems.
I am using the ember background video plugin. I've got that working perfectly.
{{#background-video
muted
mp4="../assets/video-bg.mp4"
poster="../assets/Main-bg.jpg"
}}
{{/background-video}}
I've setup a model to iterate through background videos loaded through the CMS (Drupal 8). I've also got this working exactly like I want. It displays the URL to the video:
{{video-bg video=model.video_bg}}
How do you get the model to display inside the addon script?
Like this:
{{#background-video
muted
mp4="{{video-bg video=model.video_bg}}"
poster="../assets/Main-bg.jpg"
}}
If video-bg is a helper you can use it as subexpression:
{{#background-video
muted
mp4=(video-bg video=model.video_bg)
poster="../assets/Main-bg.jpg"
}}
However this will not work if video-bg is a component. Then there is no way to do this in the template layer, and you need to refactor to either video-bg being a helper, or probably better, being a computed property.

Zinnia Templates for List and detail view

I am trying to integrate zinnia into a django application. I have to adept the zinnia templates into my theme. Now I am stuck, because it seems that zinnia is using the same template to build the blog entry list, and the blog entry detail page.
This is problematic because, the list has significant different html and css as the entry single view. How do I split the templates, so that I have one that is entirely for the list and one for the entry's detail (Single Post) ?
To the best of my knowledge this isn't easily done. Here is a comment on a bug asking about this very issue:
Template Documentation #383
For me I am going to modify zinnia/_entry_detail_base.html and put my list view template code in an {% if continue_reading %} and the detail template in the else branch.
I'm currently in the process of integrating the Zinnia engine into custom templates -- I'm working on a dynamically updating homepage that shows recent entries from multiple categories, custom pages for each of those categories, and then custom templates for the entries' detail views. I've found this question's answer and this explanation to be extremely helpful.
*Keep in mind that the second link is a bit dated, and that {% load zinnia_tags %} is now {% load zinnia %}.
It's still a lot of trial and error to get things adapted properly to a custom template, but Zinnia really is amazingly customizable, and I think its default configuration tends to overshadow the fact that it works brilliantly as an underlying engine that can power just about any framework that you can sketch out on a notepad.
As the documentation notes, it's also helpful to take a look at some custom themes built for Zinnia on GitHub, just to get a feel of how the template tags are implemented, and how the default templates can be overridden. Here's the repo for a Bootstrap theme, and here's one for a Foundation theme.

Combining Django Templates and Polymer

I've been stuck for the past few hours trying to figure out why the core Polymer elements are not being displayed properly in a Django application I'm making to act as a personal webpage. The application at the moment just points to an index.html page which, if you follow the tutorial on Polymer, is up to step one.
However, the components are not loading on my page. The static files are all set up correctly, and there's subtle animation from the css files being loaded correctly, but the Roboto font and the core-elements are not being displayed. Running the site as a normal HTML file does everything correctly.
Is there a specific way to user Polymer in a Django template?
Thanks.
See Eric's answer to this on the polymer-dev mailing list: https://groups.google.com/forum/?fromgroups=#!searchin/polymer-dev/django/polymer-dev/N2R8qknalOI/58ZhC1gWFh4J
Relevant excerpt:
Django 1.5 has support for the verbatim tag. You can wrap your inlined element definitions in that:
https://docs.djangoproject.com/en/1.5/ref/templates/builtins/#verbatim
Example code snippet:
{% verbatim %}
<template repeat="{{item as items}}">
<my-element name="{{item.name}}"></my-element>
</template>
{% endverbatim %}
<script>
document.querySelector("template').model = {{items}}; // items here is filled by the server's template.
</script>
I'm pretty sure this has to do with the fact that Django uses the same {{}} in its templates as Polymer.
I'm adding this answer as a compliment to the already accepted answer.
You can force django to require a space for it's template tags. So for any django template tags you have to use {{ variable }} and for polymer you will use {{variable}}.
Here is a very simple module/app I created to "prepare" django for use alongside polymer.
https://github.com/andrewebdev/django-ostinato/blob/2c435dea23319be6e9011e7381afca2b4092b5a2/ostinato/polyprep/init.py
Credit goes to https://github.com/nebrybledu for this suggestion.

Including a small app into a Django template

I am starting out in Django and haven't been able to find an answer to this question in tutorials or elsewhere. It seems like a simple feature, so I wonder if I am not understanding - so anyone that can explain it clearly would be greatly appreciated.
Say I have a site with 5 different pages via Django templates. If I write a small app that renders a poll (like the django tutorial), but I don't want that app to have its own url, just to feature, for example, in a sidebar of 2 of the 5 pages. The poll app has nothing to do with the other pages/apps.
My first thought was to go to those 2 pages' templates and include the template for the poll app - {% include "poll.html" %} ... I then found out this renders only the html as is, but I need to reference the database models to render a list of polls.
Inheritance doesn't quite make sense to me in this instance...
So, what would be the best practice way of doing this? For me, this is the whole idea of plug and play apps that Django is good for, but can't figure out how to just plug it in to other templates! I really just want to know the simple theory behind doing this, because it seems like a key feature.
Thanks!
Template tags - specifically, inclusion tags - are what you want.