CMS Development

KajBob
Participant

help with using module_block

SOLVE

I tried looking for references in the docs but this is all I could find about it, no other documentation, no explanation on the parameters. 

 

{% 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 %}

 

 

I have been using widget_block for a while, and I tried to get this new module_block to work but it wouldn't.  Is there any difference between using module_block, versus the traditional module @hubspot/rich_text?

 

 

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

help with using module_block

SOLVE

widget_block has been deprecated and module_block is basically just a version 2 of it. It uses the exact same code pattern as widget_block, only major difference to keep in mind is that the type_of_module will usually never change from module whereas in widget_block it would be things like rich_text or raw_html. You can read a slightly more in depth explination on that here - https://developers.hubspot.com/docs/cms/building-blocks/modules/using-modules-in-templates#block-syn...

 

The code you've posted is more an example of if you're accessing a custom module.  You can still access default HubSpot modules with module_block same as you would with widget_block. That code would look something like this:

{% module_block module "my_rich_text_module" path="@hubspot/rich_text.module", label="Rich Text" %}
    {% module_attribute "html" %}
        <div>My HTML block</div>
    {% end_module_attribute %}
{% end_module_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 using module_block

SOLVE

widget_block has been deprecated and module_block is basically just a version 2 of it. It uses the exact same code pattern as widget_block, only major difference to keep in mind is that the type_of_module will usually never change from module whereas in widget_block it would be things like rich_text or raw_html. You can read a slightly more in depth explination on that here - https://developers.hubspot.com/docs/cms/building-blocks/modules/using-modules-in-templates#block-syn...

 

The code you've posted is more an example of if you're accessing a custom module.  You can still access default HubSpot modules with module_block same as you would with widget_block. That code would look something like this:

{% module_block module "my_rich_text_module" path="@hubspot/rich_text.module", label="Rich Text" %}
    {% module_attribute "html" %}
        <div>My HTML block</div>
    {% end_module_attribute %}
{% end_module_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 using module_block

SOLVE

thanks for your help!

0 Upvotes