CMS Development

matttunney
Top Contributor

Determine first, last or count of a module

SOLVE

Is there a way to get the count for each instance of a custom module?

 

Say a module is this

 

        </div>
    </div>
</div>
<div class="row-fluid-wrapper">
    <div class="row-fluid">
        <div class="span12">

 

Is there a way to say on the first instance do this?

 

{% unless moduleCount == '1' %}
        </div>
    </div>
</div>
{% endunless%}
<div class="row-fluid-wrapper">
    <div class="row-fluid">
        <div class="span12">

Thanks

0 Upvotes
1 Accepted solution
matttunney
Solution
Top Contributor

Determine first, last or count of a module

SOLVE

So Ive found a work around but it really feels like a hack and additional effort for my marketing team. It also leaves room for error.

 

A user will need to know the set the appropriate check box (first_container, last_container) to set the divider section as either the first of last item.

this will then dictate if the closing and opening html is rendered on the template.

 

 

{% unless module.first_container %}
</div><!--end widget-span -->
</div><!--end row-->
</div>
{% endunless %}

{% unless module.last_container %}
<div class="row-fluid-wrapper new-section {{ module.background.color }}" id="{{ module.section.id|replace(' ', '')|lower) }}">
<div class="row-fluid page-center {{ module.section.width }}">
<div class="span12">
{% endunless %}

This means I can provide a template that consitists of a single flexible column. This divider section module can be dropped in where required. This will create a new section in the page with custom display settings to suit the design.

 

 

The reason for looking at a solution for this is to provide marketing staff and content editors a little of the freedom of the template generator in the design manager, without the required knowledge, so they can generate the layout the need with the modules provided.

 

View solution in original post

0 Upvotes
2 Replies 2
roisinkirby
HubSpot Product Team
HubSpot Product Team

Determine first, last or count of a module

SOLVE

Hey @matttunney I haven not personally seen this done before, but would not consider myself an exeprt in HubSpot CMS design!

 

@Gonzalo do you know if this is possible?

0 Upvotes
matttunney
Solution
Top Contributor

Determine first, last or count of a module

SOLVE

So Ive found a work around but it really feels like a hack and additional effort for my marketing team. It also leaves room for error.

 

A user will need to know the set the appropriate check box (first_container, last_container) to set the divider section as either the first of last item.

this will then dictate if the closing and opening html is rendered on the template.

 

 

{% unless module.first_container %}
</div><!--end widget-span -->
</div><!--end row-->
</div>
{% endunless %}

{% unless module.last_container %}
<div class="row-fluid-wrapper new-section {{ module.background.color }}" id="{{ module.section.id|replace(' ', '')|lower) }}">
<div class="row-fluid page-center {{ module.section.width }}">
<div class="span12">
{% endunless %}

This means I can provide a template that consitists of a single flexible column. This divider section module can be dropped in where required. This will create a new section in the page with custom display settings to suit the design.

 

 

The reason for looking at a solution for this is to provide marketing staff and content editors a little of the freedom of the template generator in the design manager, without the required knowledge, so they can generate the layout the need with the modules provided.

 

0 Upvotes