I’m trying to describe what I try to attempt
I’m using custom widgets to manage some content of a blog post that is supposed can’t be editable by de final user (client requirement ) instead should be edited by the content tab using widgets so I need to find a way to modify the post_body content passing the values of the widgets or trying to concatenate them
example I got these widgets
{{ content.widgets.widget_subtitle.body.html }}
{{ content.widgets.widget_post_content.body.html|truncatehtml(2000, “…” , false) }}
{{ "Related: " ~ content.widgets.widget_related.body.html }}
so I’d like to contact all of these values of the widgets in a unique text and pass it to the {{ content.post_body }}
I’m trying {{ content.post_body ~ “concat content” }} but this only concat the text to the box of the content post body not inside the “rich text” of the blog post content
also, the main purpose is to include the widget information inside the content post body to use for migrating posts, be available in the RSS feed, etc. Or is needed to manage all the content with the default blog content.post_body ?
Thank you all ![]()
Hi, @JCorrea7
Thanks for your question. And thank you for including some details and context. This helps our community help you.
I’d like to tag some community members into the converstaion — @Anton @alyssamwilie @HFisher7 @JBeatty, do you have any recent experience with a use case like @JCorrea7 is describing?
If not, do you have any thoughts on other ways they can accomplish their goals?
Thank you very much! — Jaycee
Hi @JCorrea7,
I’m not sure if you can pass data into the post_body element since it’s used as a drag&drop area now. What you could do is getting rid of the post_body element completly and create yourself a custom solution/module. This was a common practise before the drag&drop functionality in blog posts.
Basically you create a custom repeater module as/for blog post functionality with some nested loops. I’d say it’s a bit on the advanced side since you have to create every possible layout beforehand(of course you can extend it later) but the modules could reach easily several hundreds of lines of code and weren’t easy to maintain if it wasn’t documented well.
Also the biggest downside of not using the blog_post function is that you’ll have to create custom blog cards if you want/need a short preview text per blog post since it’s generated from the post_body element by default.
A possible layout of such a repeater module could look like this:
{% for row in module.rows %}
{# if row.type == "text" #}
{# start (rich) text #}
{{ row.text }}
{# end (rich) text #}
{% elif row.type == "image" %}
{# start image #}
...
{# end image #}
{% elif row.type == "headline" %}
{# start headline with subline #}
<{{row.headline_text.h_tag}} class="{{row.headline_text.headline_class}}">{{row.headline_text.headline}}</{{row.headline_text.h_tag}}>
<{{row.headline_text.subline_tag}} class="{{row.headline_text.subline_class}}">{{row.headline_text.subline}}</{{row.headline_text.subline_tag}}>
{# end headline with subline #}
...
{% endif %}
{% endfor %}
This code above contains following functions:
- rows(group;repeater)
- type(choice)
- text(option)
- Image(option)
- headline(option)
- text(rich-text; only visible if the user selects “text” in the type field)
- image(image; only visible if the user selects “image” in the type field)
- headline_text(group; only visible if the user selects “headline” in the type field)
- H-tag(choice)
- Headline class(choice or text)
- Headline(text)
- Subline-tag(choice)
- Subline class(choice or text)
- Subline(text)
- type(choice)
You can create all sort of functions with this but again: It’s quite a task and can take several weeks to write everything(you’ll maybe need CSS and JS functions)
Hope this helps,
best,
Anton
