This works like a charm but there is a problem i cant solve. All blog posts have an additional rich-text module (module_1587387572139353). I need to separate the intro text from the blog content because of design reasons. Now i need to access this rich text field in my custom related posts section and create the output of the field inside the p.intro-text field. As you can see i tried different solutions but nothing is working.
The related blog posts section is inside my Hubl Blog-Post theme at the bottom of the current blog post.
The output of this field will be HTML, including the tags that are present in the rich text module. Based on your module's default text, this will have a <p> tag. If you don't want that, you could either edit the HTML of the module in the post to have no HTML tags, you could change the module to a regular text field instead of rich text, or you could use the striptags filter to remove the HTML from the macro output:
Depending on what you intend the final output to contain and look like, I might recommend changing to a regular text field, or updating the macro to remove the wrapping <p> tag around the module output.
I think this should just require one minor udate to work. Calling the rich text module in the post formatter will need to change slightly, I believe the following should work:
{{post.widgets.module_1587387572139353.html}}
The changes here include putting "post." at the front, changing "widget_data" to "widgets", and "default" to "html". Updating to the above snippet should work for you.
Apr 22, 20209:16 AM - edited Apr 22, 20209:17 AM
Contributor
Get content of Blog-Article rich-text module in custom related blog posts
SOLVE
Hi BenSBM
Tank you so much for your help!
I tried yous snippet but there is still no output. Maybe you need to have a look at my module. I created it by creating a HubL template from a drag and drop template
This will allow the module to be referenced elsewhere, but will also affect the regular blog post output as well, and would require updating the post template to be able to output the module content:
The output of this field will be HTML, including the tags that are present in the rich text module. Based on your module's default text, this will have a <p> tag. If you don't want that, you could either edit the HTML of the module in the post to have no HTML tags, you could change the module to a regular text field instead of rich text, or you could use the striptags filter to remove the HTML from the macro output:
Depending on what you intend the final output to contain and look like, I might recommend changing to a regular text field, or updating the macro to remove the wrapping <p> tag around the module output.