CMS Development

theAndreyK
Mitwirkender/Mitwirkende | Partner
Mitwirkender/Mitwirkende | Partner

Any existing strategies to create re-usable Module Groups?

I'm new to Hubspot so hopefully someone has already come up with a perfect solution for this but I can't seem to find it. 

 

I'd like to create a grouping of content, let's say a line of text and an image, and then re-use that grouping multiple times in a template. Does that exist? 

 

Idea #1

The closest thing I've been able to come up with is creating a custom module and then modifying its contents in the "website" editor after building the template. This is not ideal for numerous reasons and would still require duplicate work across pages. 

 

Idea #2

Not technically a solution but I guess I could just make re-make little groups over and over again every time I need one. At least in this case I could benefit from global groups and re-use them on a large scale. 

 

Idea #3

...

 

Thanks guys. Would appreciate any thoughts. 

0 Upvotes
3 Antworten
ashleyidesign
Stratege/Strategin | Partner
Stratege/Strategin | Partner

Any existing strategies to create re-usable Module Groups?

Couple of questions, is this content going to be the same all the time, or different?

 

Are you wanting to add them at the page level to flex columns or are you just adding them to templates?

 

Two choices, either custom module, or global group.

 

Global groups you can't add to flex columns yet, but would be fine for adding into page templates themselves.

 

Custom module you can add to flex columns but you're thinking you'd have to edit the content all the time.

 

I actually ran into this same issue with a client's site, so what I did was create a custom module but only have the image field editable. The content itself is hard-coded in the HTML as it won't change. The images are set by default, and if they wanted to remove one of the content sections, they just remove the image.

 

Changing the hard-coded content in the custom module would affect all pages the module was on, instead of having to customize the module on each page.

theAndreyK
Mitwirkender/Mitwirkende | Partner
Mitwirkender/Mitwirkende | Partner

Any existing strategies to create re-usable Module Groups?

Couple of questions, is this content going to be the same all the time, or different?

The content would be different but the structure of the content would be the same. 

 

Are you wanting to add them at the page level to flex columns or are you just adding them to templates?

Adding them to templates.

 

Global groups you can't add to flex columns yet, but would be fine for adding into page templates themselves.

The problem here is that global groups always use the same content and cannot be converted to local copies. 

 

It looks like the only solution here is to use custom modules or duplicate efforts while buiding out the template. At least until Hubspot updates their COS to handle this case. 

 

0 Upvotes
Gonzalo
Stratege/Strategin | Diamond Partner
Stratege/Strategin | Diamond Partner

Any existing strategies to create re-usable Module Groups?

hi!

To handle this limitation in HS usually I go with Macros.

 

Idea #3 😄

Create a macro for the repeteable structure and send in variables your content:

 

 

{# Creating the macro #}

{% myMacro (variable1,variable2) %}
<div class="span12 custom-block">
  <h3>Custom & fixed structure</h3>
<div class="simple-var">{{variable1}}
<div class="custom-content-extra-html-inside">{{variable2}}</div>
</div>
{% endmacro %}


{# Setting my first vars #}
{% set text_var = " Simple text content" %}
{% set text_html = '<p>Complete variable with html</p>
                               <div class="mycustom-class"> Also supports breaklines 🙂 </div>' %}


{# Calling the macro with my vars #}
{{ myMacro(text_var,text_html) }}

 

I also recomend put this kind of HubL code inside a html file (for example: custom/system/projectX/macros.html) . This way everything will be ordered and cleanest and you can call in the template with something like:

 

{% import "custom/system/projectX/macros.html" as macros %}

And then you can call the macro from inside the variable macros:

 

 

{{ macros.myMacro(text_var,text_html) }}

 

I hope this could help you! 🙂

 

Regards,

Gonzalo

 

 

If this answer helps you to solve your questions please mark it as a solution.

Thank you,


Gonzalo Torreras

HubSpot freelance developer

hola@gonzalotorreras.com
www.gonzalotorreras.com
Schedule a meeting