CMS Development

Cristi
Member

Module Repeater

Hi everyone,

 

I want to build a section for listing reviews on different landing pages that are using the same template.

The idea is that at the moment I've created a module and replicated it like 50 times, this looks ugly and seems a bit hard to administrate, also I don't find it like a good way to do it.

 

So my question is, is there a way I can dynamically replicate a module so I can add one more reviews module whenever I need on a landing page. There are like 50 landing page each one with its own list of reviews, so this is why I need to have it dynamically added, and because in time there will be others added and I don't want the editor to lose his head with these.

 

If this is not possible, is there a way I can loop through the 50 modules created so I don't write each one of them in the template?

Also, I'm sorry for not providing more details or for not using more technical terms you guys are used around here as I'm new at using HubSpot.

 

Thank you in advance.

0 Upvotes
11 Replies 11
Jsum
Key Advisor

Module Repeater

@Cristi,

 

You will find a tutorial here. for some reason there is a red bar at the top of this page stating that one of the techniques here is deprecated and no longer supported, but I have used this exact method about a hundred times on various websites so you should be able to use it to do what you are wanting. 

 

Need help? Hire Us Here

0 Upvotes
Cristi
Member

Module Repeater

Hi @Jsum

 

Thank you for your response and for the provided link, I've found that before in order to create loops. But this will work only to list the 50 modules in the template without having to add each include line for each module, right? 

 

Does the same method you have provided me also works to dynamically replicate modules on a landing page? What I essentially need is an "Add new Review" button that adds a new module each time I press it or another option that would work is to change the total number of Reviews available for one landing page. Do you think this is possible?

 

Regards,

Cristian

0 Upvotes
Ty
HubSpot Employee
HubSpot Employee

Module Repeater

Hi @Cristi,

 

In terms of being able to dynamically generate modules from the listing page, there isn't really a great solution. David Hunt wrote the repeater module, but even that has flaws, one of the main ones being it doesn't number you modules.

 

What I've found is helpful is using a flex area of a template, then creating the reviews in a custom module. Take a look at this page, for example. When we built this listing page, we needed it to be simple to create a new module. This is done using the flexible column module, the template mainly looks like this:

Screen Shot 2017-07-13 at 9.41.01 AM.png

Flexible columns allow you to creat a container that you can fill up on your page-level editor. So you would set this module, then create a custom module with all of your information for a review.

for example (explanational purposes):

<div class="review-box">
  <h3>John Doe</h3>
  <h4>Movie Title</h4>
  <p>This is John Doe's review...</p>
  <span="rating">★★★☆☆</span>
</div>

Then you'd have a module for each one of those sections.

 

Now that you have the custom module, you create the page and you can drag multiple versions of this module into the flex column, like so (page editor view).

Screen Shot 2017-07-13 at 9.46.37 AM.png

When you click on one of your modules, you'll be able to edit the custom fields within them as well.Screen Shot 2017-07-13 at 9.48.32 AM.png

----------------

It's not the perfect solution, but it's one of the better ones I've come up with trying to solve this problem. Some pros and cons I've run into:

 

Pros:

- You can do a ton of interesting stuff with some custom scripting, for example of the page I showed you, I'm able to paginate it from client side (which allows me to search all the modules, but only load the visible ones).

- You don't need to know any code to add a new review

- You don't need to create tons of modules in the template editor

- Relatively light weight.

 

Cons:

- You'll need some scripting magic to attach a class to the actual parent container of each one

- All modules have the same name, making clicking through them on the edit page a little annoying.

- Modules load first, then take on their css, so you will come across a FOUC error every so often.

 

Hope this helps you out! (sorry for the large screenshots!)

-- Ty

0 Upvotes
adudka
Member

Module Repeater

Hi,

 

Does anyone know why the repeater module is being deprecated? It seems I'm unable to use it in the way @Jsum has described, which I have done in the past on our current site. I am also struggling to find a viable replacement.

 

Any assistance is appreciated.

 

Thank you,

 

Andrew

0 Upvotes
Jsum
Key Advisor

Module Repeater

@adudka,

 

I am not sure what about it isn't working. Last I checked it still worked the same.

 

I have been using the beta design manager though and the new custom module interface has repeater ability built in. I have used it in every project since I started using it last month. I would give that a try if you are able to access the beta. It will make your life 100% easier.

 

Need help? Hire Us Here

0 Upvotes
Javierismo
Contributor | Elite Partner
Contributor | Elite Partner

Module Repeater

Hi @Jsum, how do you do a repeat module with an image and text? i know you can do an image gallery for example, but if i have an image + text editable, how i can make it?

0 Upvotes
Jsum
Key Advisor

Module Repeater

@Javierismo,

 

Create a new custom module in the new design manager and create an image and text field on the left. Group these two fields. Edit the group. at the bottom of the editor for the group set your repeater options. Now you have a repeating group image and text field.

 

Need help? Hire Us Here

Javierismo
Contributor | Elite Partner
Contributor | Elite Partner

Module Repeater

Yisus @Jsum !! i didin't know!

 

thanks a lot! you save me a lot of work haha

Jsum
Key Advisor

Module Repeater

@Javierismo, glad I could help! Remember to mark a solution.

 

Need help? Hire Us Here

0 Upvotes
Jsum
Key Advisor

Module Repeater

@Cristi,

 

@Ty,

 

Flexible modules are a nightmare when it comes to hubl. like you said, it takes some magic. I'm not knocking it i'm just saying. 

 

With the repeater module, the only flaw is that you have to refresh the editor after adding new modules. You can number the modules by appending the index number to the module label using block syntax. Any issues that the tutorial in question presents can be overcome by just stepping the logic up a notch.

 

If you using the template builder and you want to use flexible modules, you can create a custom module for the review block and add it as many times as you want on the page editor. You could do the same thing in code as well. I don't like or recommend flexible modules because they are fickle. Thats just me though.

 

Need help? Hire Us Here

Jsum
Key Advisor

Module Repeater

@Cristi,

 

It's not a button as much as a drop down of numbers. Select the amount of modules you need printed, save, and refresh the page and that many of the module (or set of modules) will be added to your page editor.

 

Need help? Hire Us Here

0 Upvotes