However, currently "content.post_body" is returning nothing as we are using custom modules to populate the blog post and not the standard Blog Content/Rich Text module. Is there a way I can get the HTML of the whole page, or access the HTML in the other modules to then calculate the read time?
I would try to concatenate all of the "rich-text" values into a single hubl like
{% set total_readtime = module.rich_text_1 ~ module.rich_text_2 ...%}
and then modify the read time code to this:
{% set initialPostWords = total_readtime|striptags|wordcount %}
{% set calculatedPostWords = (initialPostWords/100) * 100 %}
{% set finishedPostWords = calculatedPostWords|divide(300)|round(2) %}
{% set number = finishedPostWords|round %}
{% if number < 1 %}
{% else %}
{{ finishedPostWords|round }} minute read
{% endif %}
Just a quick tipp: you should use the default "content.post_body" option somewhere in the post. Maybe for the "intro". Otherwise you'll need to rewrite module like "latest posts" or similar (all modules which displays some kind of blog information preview)
I would try to concatenate all of the "rich-text" values into a single hubl like
{% set total_readtime = module.rich_text_1 ~ module.rich_text_2 ...%}
and then modify the read time code to this:
{% set initialPostWords = total_readtime|striptags|wordcount %}
{% set calculatedPostWords = (initialPostWords/100) * 100 %}
{% set finishedPostWords = calculatedPostWords|divide(300)|round(2) %}
{% set number = finishedPostWords|round %}
{% if number < 1 %}
{% else %}
{{ finishedPostWords|round }} minute read
{% endif %}
Just a quick tipp: you should use the default "content.post_body" option somewhere in the post. Maybe for the "intro". Otherwise you'll need to rewrite module like "latest posts" or similar (all modules which displays some kind of blog information preview)
Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success. Don't miss this opportunity to connect and grow—reserve your spot today!