Wordpress shortcode not working in twig page template - wordpress

I'm using Gantry5 framework (with the g5_hydrogen theme) and I created a twig page template which works fine, except the shortcode for the Contact Form 7 plugin apparently does nothing - the form does not display on the page, and when I inspect the element in my browser I just see some blank space between the div tags. My current markup is something like this:
{% block content %}
<content>
<div class="dbc-contact-form">
{{ wp.do_shortcode('[contact-form-7 id="1234" title="Contact"]') }}
</div>
</content>
{% endblock %}
Someone else posted a similar question before, but unfortunately that solution doesn't help in my case - Wordpress twig template shortcode not displayed
Thanks for your help with this.

Try this - {{ post.post_content|shortcodes }}

Related

How can I display image of dynamic field in drupal 8?

I am new to learning Drupal 8.
I need your help in how can i display dynamic images using Twig template. Also I have tried with below syntax.
{{ file_url(market.getFieldCollectionItem().field_turnpike_image.entity.uri.value|e) }}
{{ file_url(media.entity.field_image.entity.uri.value) }}
Using above syntax I could not display images using in twig template. Also with this syntax I have got some errors.
Please any one help me out to how can i display images using twig template.
Thank you.
Use the following snippet to get the image if you are in node twig template
{{ file_url(node.field_image['#items'].entity.uri.value) }}
even
{{ node.field_image.entity.url }}

django cms menu: display page title alongside the page's menu title

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!

CollectionType custom prototype via form_theme

I want to customize the way an entry of a CollectionType in a form will be rendered, that is the way the prototype is generated, I need my own HTML. So I need to do it with the Twig form_theme, but it doesn't work.
I am currently using Symfony 4.1.2.
Here is what I have for now:
In the template that renders the whole form:
{% form_theme form.additionalEmails.vars.prototype 'form/additionalEmail.html.twig' %}
In the form/additionalEmail.html.twig file:
{% block form_row %}
<div style="margin: 10px 0">
{{ form_label(form) }}
{{ form_widget(form.children.value) }}
<div>Recevoir les mails de type : {{ form_row(form.children.isUsedForAdminCommChannel) }}{{ form_row(form.children.isUsedForInfosPratiquesCommChannel) }}{{ form_row(form.children.isUsedForAgendaCommChannel) }}</div>
</div>
{% endblock %}
If I do that I get this error:
Key "value" does not exist as the array is empty.
What is weird is that if I replace the above code by this (by commenting the old one and adding the new line):
{{ dump(form.children) }}
I see that form.children is an array with 4 items and one named "value" so it is clearly broken.
Your help would be much appreciated, as I'm just an amateur dev trying to make a website for a youth movement ^^
Best Regards,
[EDIT]
Here is the form that includes the CollectionType:
https://gist.github.com/MrPOC/a4af94cc5e577a1244dac59de5ea3506
The field is named "additionalEmails"
Just so I understand you correctly. You have a Form which contains a CollectionType and you want to change the prototype of that CollectionType?
If yes could you please post the Form with the CollectionType?
EDIT: Ok so here's how to overwrite the prototype template for a CollectionType.
First we have to find out what your forms unique_block_prefix is. You can find this by going to the page where this form is rendered, you then click in the symfony debug bar on the form icon. Then you have to expand the View variables block and look for unique_block_prefix.
I assume your block prefix could look like this _user_type the name of the block you would overwrite would then be _user_type_additionalEmails_entry_widget (for more details please read the link provided below)
You can replace the widget part with row or label depending on what you want to overwrite (I would suggest trying to overwrite them all to see what exactly changes because I don't know of the top of my head)
In twig you would then take your block prefix and overwrite the prototype field in the same way you would overwrite any other field
{% block '_user_type_additionalEmails_entry_widget' %}
//Content
{% endblock %}
What I wrote down here is what I found out after reading https://github.com/symfony/symfony-docs/issues/6056 (read HeahDude' comment specifically)
I hope this helps!

Symfony - translations stop working after rendering controler in another's view

I'm building a webiste, where there will be lots of "widgets" displayed on the front page. One of them is the calendar.
I wanted to make a new controller for each this "widget", and then render them all (like the example below), in the Homepage view.
Hovewer - the translations stop working after that. If I visit mywebpage/calendar, they work, but not when I got to mywebpage/home.
This is the code I currently have for my Homepage view.
{% block Calendar %}
{{ render(controller('MyWebsite:Calendar:index')) }}
{% endblock %}
Am I approaching this correctly or not? And why do the translations stop working?
Also - I hope you will understand what the issue is :)
Thanks!
I am surprised that doesn't work, do you have anything else in your app interfering with the Request object?
Maybe passing the locale from the request as an argument to the controller may work (although a bit of a hack)?
{% block Calendar %}
{{ render(controller('MyWebsite:Calendar:index', { _locale: app.request.locale })) }}
{% endblock %}

Creating 'News' section with cmsplugin_blog Django CMS application

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

Resources