CMS Development

MLerner
Membre

Add Module after certain number of words in blog post?

Résolue

I wanto have a certain module embedded in the text of my blog posts after, let's say 300 words. Is there a way to do this with Hubl to say "add module x after 400 words"?

0 Votes
1 Solution acceptée
Kevin-C
Solution
Expert reconnu | Partenaire solutions
Expert reconnu | Partenaire solutions

Add Module after certain number of words in blog post?

Résolue

Hey @MLerner 

 

I would use javascript to solve this! This might help.

@Teun's solution is a solid one, but since the blog post is rich text, it's full of html tags and I think that'll give you issues.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

Voir la solution dans l'envoi d'origine

3 Réponses
Kevin-C
Solution
Expert reconnu | Partenaire solutions
Expert reconnu | Partenaire solutions

Add Module after certain number of words in blog post?

Résolue

Hey @MLerner 

 

I would use javascript to solve this! This might help.

@Teun's solution is a solid one, but since the blog post is rich text, it's full of html tags and I think that'll give you issues.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
Teun
Expert reconnu | Partenaire solutions Diamond
Expert reconnu | Partenaire solutions Diamond

Add Module after certain number of words in blog post?

Résolue

Hi @MLerner ,

 

Gotta agree with @Kevin-C , above solution could give issues. Worth a shot if you do not want to use scripts.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


Teun
Expert reconnu | Partenaire solutions Diamond
Expert reconnu | Partenaire solutions Diamond

Add Module after certain number of words in blog post?

Résolue

Hi @MLerner ,

 

You could try something like this:

 

{% set wordArray = module.content|split(' ') %}
{% set contentArray = wordArray.insert(400, 'set your HubL for the module here') %}
{% set content = contentArray|join(' ') %}

{{content}}

 

This is not tested, not sure if HubL will work if it is passed as a string, but could be worth a try. Change the 400 to any index you want.

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.