CMS Development

LSeth
Member | Platinum Partner
Member | Platinum Partner

Loop through crm_objects batches

SOLVE

Hello. I am using a module on a dynamic page to display crm_objects. Of course there is the limit on how often on a page crm_objects can be used. How would I loop through to display them in batches? I assume I would use the has_more and offset but can't seem to get a loop working.

 

Can you also paginate the results? Thanks.

0 Upvotes
1 Accepted solution
Anton
Solution
Recognized Expert

Loop through crm_objects batches

SOLVE

Hi @LSeth

to loop through a crm_object you have to use the dynamic_page_crm_object_type_fqn  option and loop/repeater.

 

build into the template it should look something like this:

 

 

 

{% if dynamic_page_crm_object_type_fqn %} {# the listing page #}
{% set object = crm_objects(dynamic_page_crm_object_type_fqn, "limit=200","put, all, your, custom, object, properties, here") %}

{% for single_object in objects.results %}
<div class="object-wrapper">
<div class="names">
{{ single_object.put }} {{ single_object.all }} {{ single_object.your }}
</div>
</div class="something">
{{ single_object.your }} {{ single_object.custom }} {{ single_object.object }}
</div>
{% if single_object.properties == "here" %}
{{ single_object.here }}
{% endif %}
{% endfor %}

{% elif dynamic_page_crm_object %} {# the detail page #}
{# layout for detail page; you can use the objects set above or add more by adding a second "set object = ..." #}
{% endif %}

 

 

 

If you'd like to categorize the listing page you could add/use a property like a dropdown/select for this (see the if statement above)

 

About the pagination - have to test this.

 

But tbh, this seems to become something that you could easily use a blog for. Write your blog listing/post templates and put your CRM objects into them. 

 

Also - custom objects were the topic of our october DHUG. You can watch it on YouTube

 

best, 

Anton

Anton Bujanowski Signature

View solution in original post

0 Upvotes
2 Replies 2
Anton
Solution
Recognized Expert

Loop through crm_objects batches

SOLVE

Hi @LSeth

to loop through a crm_object you have to use the dynamic_page_crm_object_type_fqn  option and loop/repeater.

 

build into the template it should look something like this:

 

 

 

{% if dynamic_page_crm_object_type_fqn %} {# the listing page #}
{% set object = crm_objects(dynamic_page_crm_object_type_fqn, "limit=200","put, all, your, custom, object, properties, here") %}

{% for single_object in objects.results %}
<div class="object-wrapper">
<div class="names">
{{ single_object.put }} {{ single_object.all }} {{ single_object.your }}
</div>
</div class="something">
{{ single_object.your }} {{ single_object.custom }} {{ single_object.object }}
</div>
{% if single_object.properties == "here" %}
{{ single_object.here }}
{% endif %}
{% endfor %}

{% elif dynamic_page_crm_object %} {# the detail page #}
{# layout for detail page; you can use the objects set above or add more by adding a second "set object = ..." #}
{% endif %}

 

 

 

If you'd like to categorize the listing page you could add/use a property like a dropdown/select for this (see the if statement above)

 

About the pagination - have to test this.

 

But tbh, this seems to become something that you could easily use a blog for. Write your blog listing/post templates and put your CRM objects into them. 

 

Also - custom objects were the topic of our october DHUG. You can watch it on YouTube

 

best, 

Anton

Anton Bujanowski Signature
0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Loop through crm_objects batches

SOLVE

Hi, @LSeth 👋 Thanks for your question. I'd like to invite a few community members to the conversation — hey @alyssamwilie  @piersg @Anton, do you have any tips you can offer @LSeth

 

Thank yo very much for taking a look! —Jaycee 

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot