DnD in blog posttemplate

Hello!

I have read other threads where it was mentioned
the dnd_area function works only in blog_listing. It doesn’t work in blog_post templates.

Is this still the case? If not, I am trying to add DnD sections to the blog template, not blog posts, so client can create the blog template the way he wants.
I’ve been trying some workarounds but getting stopped at
“The template can’t contain “dnd_area” modules. Please remove “dnd_area” on line 14.”
This is my code:

<!--
 templateType: blog_post
 isAvailableForNewContent: true
 label: Blank
 screenshotPath: ../images/template-previews/blank.png
-->
{% extends "./layouts/base.html" %}

{% block body %}
{% dnd_area "dnd_area"
 label="Main section"
%}

{% end_dnd_area %}
{% endblock body %}

But if it can’t be done, then nevermind the code!
Thanks in advance,
Ben

Hey @bblue6 yep! You can’t use D&D areas in email templates and blog post templates according to the documentation. Blog posts are a big weird to be honest, you can technically add modules into the blog post body, but it will cause a issues usually. Blog posts are pretty static templates as they need to pull the main blog post body info into them.

Hey @bblue6, As of the latest HubSpot CMS documentation, drag-and-drop (DnD) areas (dnd_area) are still not supported in blog_post templates. Your code is being rejected with the error:


“The template can’t contain “dnd_area” modules. Please remove “dnd_area” on line 14.”


because HubSpot restricts the dnd_area usage of certain template types, specifically page, email, and blog_listing templates, not blog_post.
As an alternative, you can use custom modules for editable content, but not dnd_area.

Well i found in the docs, here, that
Drag and drop areas can’t be used in blog post and email templates at this time.
So my questions is what else may come close? Use Smart Content or Custom Modules maybe? I am more than comfortable coding, in any capacity, I just happened to have not done a lot of it here. My end need is for client to be able to use DnD or similar so he can create the blog post template he wants without going in the HTML / code. But i am more than happy to go in there to get any kind of workaround or close match going.
Thanks!

Hey @bblue6,

the blog_listing supports dnd_areas, but as the fellow people here mentioned - the blog_post doesn’t.
But this doesn’t mean that you can’t have a dnd experience in the blog post.

But there are a few things to keep in mind:
The “dnd area” for the blog post is

{{ content.post_body }}

No wrappers. Just this code.

How it works is that it will allow you/your user to creating the post itself with a “rich-text” but you can drop any module in between the rich-text. The only downside is: It’s only one column, so you can’t have something like “multi-column” layouts…

unless :grinning_face:

you create custom modules with the desired layout.
This means, you could have a custom module with 2,3… columns, super crazy setups&functions etc. This will work because it’s one single module.

So simply create a custom module with the desired layout and functionality, make it available for blog posts and you’re good to go

best,

Anton

Hi again, @Anton I am wanting to try this.
How it works is that it will allow you/your user to creating the post itself with a “rich-text” but you can drop any module in between the rich-text. The only downside is: It’s only one column, so you can’t have something like “multi-column” layouts…

How can i test this? Just add this

{{ content.post_body }}

to my blog post template? I can only have one in the account - one blog - so will doing this affect my already published blog posts?

And what do you mean by “in between the rich text”? Maybe i’ll see easily but i needed to be sure about my first point first.

Thanks!

Hey @bblue6,

every blog post template should have the

{{ content.post_body }}

as this is what allows you to write the actual post. I’ve just calling it Rich-text. Simply because technically, it is one.

As you’re writing the post, you can drop modules in between paragraphs (see screenshot taken from my dev environment)

So yeah, you can write a post and drop your (custom) modules in between text.

As you got only one blog, which I assume works perfectly fine, you don’t need to change anything. You can create custom modules and drop them in every blog post as you need it.
Note: You cannot “predefine” modules and such like in website and other dnd templates. So you’ll need to add modules in every post.

If you want to test and develop things before moving it to live portal, you can create a free developer test account at developers.hubspot.com and create up to 10(?) CMS sandbox accounts in a test account. Each CMS sandbox comes with basically enterprise functionality for developing purposes but you cannot use it for production usage. (HubSpot won’t give away fully fletched free enterprise tier accounts).

So if you want to have a seperate dev environment without worrying to destroy something, create a CMS sandbox, develop and test your stuff and once you’re happy, copy it over to the prod account.

best,

Anton