CMS Development

KajBob
Participant

Help with understanding docs for module_block

SOLVE

Hi,

 

I just started to learn more about hubspot after a long while.  I'm trying to figure out this whole modules thing by reading the docs, and I get alot of it now.  But I don't understand what this module_block thing is.  The last time I used hubspot, they were using something called widget_block, and inside that, you would use something else called widget_attribute, then put your html code inside this.  Nowadays, hubspot deprecated the old widget_block stuff to something called module.  This is fine I guess, but I'm confused on the syntax of it.  I tried reading the docs, but Im still not 100% clear on it.  You can find the section of the doc im talking about here: Using modules in templates (hubspot.com)

 

I have a bit of confusion over module_block, which used to be "widget_block", the last time I looked into hubspot a couple of months ago.  Heres some of the code they referenced in the docs under "block syntax".

 

 

{% module_block module "my_rich_text_module" path="/My Rich Text Field Module",
  label="My Rich Text Field Module" 
%}
    {% module_attribute "rich_text_field_variable" %}
       <div>My HTML block</div>
    {% end_module_attribute %}
{% end_module_block %}

 

 

So for module_block, you have the unique name and some path.  Here are some questions

  • Can you make your own custom module_blocks?  The path in the module_block looks like its a custom version
  • in the module_attribute block, theres this "rich_text_field_variable", what exactly is that, I can't find a reference to this anywhere.  Do I need to add this point if I add html?  What If I want to add an image or something else? Do I just use "image_field" or something like that?
  • Why do I use module_block for?  Can I just use one of the default modules or custom modules instead and pass the html into the value parameter?

In the docs, they mention these paragraphs.  What is this "type_of_module" stuff and what does it mean?

 

The parameter that immediately follows module_block or widget_block(deprecated) is the type_of_module parameter.

In nearly all of our documentation you will find we use module. V2 HubSpot Modules are normal modules, like what you can create. Therefore there's no longer a need to use a different type_of_module.

While widget_block is deprecated, and you should use module_block. If inheriting a website from another developer it may contain old code using widget_block and type_of_module.

 

Thanks for the clarifications!

Thanks for the clarifications!

0 Upvotes
1 Accepted solution
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Help with understanding docs for module_block

SOLVE
  • module_block is not a seperate thing from modules. It's a type of syntax for accessing modules and updating the values of the fields. Most of the time you would only be using this if you're needing to add large amounts of HTML to rich text fields as doing so in a {% module %} value can easily cause errors. The majority of the time you would just use the {% module %} syntax.
  • The example provided is for accessing a custom module where the path is the relative path to a module you have built. If accessing a default Hubspot module you would change the path to that of the default HubSpot module.
  • rich_text_field_variable is the name of the field you're updating
    richtext-vale.png
  • type_of_module is the 'module' you see directly after 'module_block' in the example. In widget_block this was usually something like rich_text or raw_html as, before going modular, HubSpot had particular types tied to their modules. So, basically, now you would never change that from 'module'. It might have been left in V2 just for the purpose of not breaking old usage of widget_block??

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

View solution in original post

2 Replies 2
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Help with understanding docs for module_block

SOLVE
  • module_block is not a seperate thing from modules. It's a type of syntax for accessing modules and updating the values of the fields. Most of the time you would only be using this if you're needing to add large amounts of HTML to rich text fields as doing so in a {% module %} value can easily cause errors. The majority of the time you would just use the {% module %} syntax.
  • The example provided is for accessing a custom module where the path is the relative path to a module you have built. If accessing a default Hubspot module you would change the path to that of the default HubSpot module.
  • rich_text_field_variable is the name of the field you're updating
    richtext-vale.png
  • type_of_module is the 'module' you see directly after 'module_block' in the example. In widget_block this was usually something like rich_text or raw_html as, before going modular, HubSpot had particular types tied to their modules. So, basically, now you would never change that from 'module'. It might have been left in V2 just for the purpose of not breaking old usage of widget_block??

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
KajBob
Participant

Help with understanding docs for module_block

SOLVE

thanks for clarifying!  I appreciate it greatly!

0 Upvotes