How do I create a generic 'News' section, that would use cmsplugin_blog and be displayed on all pages. Is it possible to tell Django CMS in base.html to include the app on all pages? The content of each news entry should be displayed in the main block of the page.
My base.html looks something like this:
...
{% block base_content %}
{% endblock %}
...
{% block right-column %}
{% endblock %}
Each page that should have a news short list in the right column with links to individual news entries that should be displayed in the base content block when clicked on the link.
One way you could do this would be to create a page which is published but not in the navigation and add an instance of the blog plugin to that page and then in your "master" template you can display the contents of that placeholder (which will be the blog plugin instance) using the following template tag:
http://django-cms.readthedocs.org/en/latest/advanced/templatetags.html#show-placeholder
Related
I want the functionality of EasyAdmin Bundle but i just want the body tag cause i have my own template and i can't seem to be able to extract only the contents of the body tag.
i tried the checking out the code but it keeps referencing other twigs
i just want what's inside the body block in html and css
{% extends 'baseback.html.twig' %}
{% block body %}
{% endblock %}
this is what i need from the bundle code."
If you look at the EasyAdmin source code:
https://github.com/EasyCorp/EasyAdminBundle/blob/master/src/Resources/views/default/layout.html.twig
You can see that body block contains everything including menus and stuff; where content block is what you want.
Now in the documentation:
https://symfony.com/doc/master/bundles/EasyAdminBundle/book/edit-new-configuration.html#overriding-the-default-templates-using-symfony-s-mechanism
You can override the above layout.html.twig in your own project to only render what you want.
I want to modify the content of the end block in the symfony. When I did inspect element at that time it is showing in model-footer. How can I modify footer content.
I want to change name from save order to save
The question is not clear but I think I know what you mean ...
Normally you have a block {% block footer%} {% endblock%} in your base.html.twig. To add content, go to the specified view by adding ...
{% block footer%}
// Your HTML Content
{% endblock%}
I want to display a plain django-cms menu. I override the default menu/menu.html template, as I want to display the page's title, alongside the page's menu title. This is for a content navigation, where the additional info of the title is useful.
The default is (in the <a></a>):
{{ child.get_menu_title }}.
What I want is
{{ child.get_menu_title }}<span>{{ child.the_page_title }}</span>
But, somehow, I cant display the title alongside the menu_title. If the field menu_title is set, it overrides the title attribute of the NavigationNode, and it is returned when calling get_menu_title (obviously). Also, the title is not in the attr (NavigationNode attr).
I just ended using
{% load cms_tags %} {% page_attribute 'title' child.id %}
This might not be ideal concerning performance, but works very well. Open but for better solutions!
I've got a Twig base template like so:
{% include "./partials/navigation.html" %}
<!-- Main Wrapper -->
<div id="wrapper">
{% block content %}{% endblock content %}
</div>
I also have a route controller which is outputting the response content to the page using twig:
return template->render('path/to/teplate', args());
where args[] array is all the data needed for this bit: (different on every page)
{% block content %}{% endblock content %}
However my sidebar is being built separately through a menu builder class, and now it needs to render the results of building the menu to my template and populating ./partials/navigation.html.
An easy solution for me is to just append the results of the Menu Builder to the returned response of every controller (I can use a base controller class to do this as this menu appears on every page). However something about this feels unclean as if I have to render the same header/footer every time as well I'll have to be append all 3 outputs to the response. (maybe that is okay?)
Is there a better way of rendering several includes worth of content which each need their own DB lookups and other server-side logic?
Yes. They are called sub requests. Read the documentation here.
I'm thinking to organize my base layout in symfony2 containing only 3 blocks: header, content, and footer. And I want to have one template for each block. The "content" template will be a template that will be empty, showing only the templates for every section, following the "3 levels" directives.
But I don't know how to include the header and footer template. I've done it creating "by pass" templates, so, for example, content extends footer, footer extends header, and header extends base, but it looks very bad.
Thanks.
you can use the embed tag, that combines the behaviour of include and extends. It allows you to include another template's contents, just like include does. But it also allows you to override any block defined inside the included template, like when extending a template,
but version 1.8 is required
The embed tag
You can't extend more than one template in Twig, it is illogical anyway.
You should use include, which is a bit different.
The common way is to have one base template, which will be extended by all the other ones, except the header and the footer that will be included in it.
base.html.twig:
...
<body>
{% include '::header.html.twig' %}
{% block body %}{% endblock %}
{% include '::footer.html.twig' %}
</body>
...
In the other templates, your bundles' views for example:
{% extends '::base.html.twig' %}
{% block body %}
Hello world!
{% endblock %}