APIs & Integrations

cmreinholz
Participante

Pull Random Record from HubDB Each Time a Page Loads

Hi,

I’m trying to display a random record from a HubDB database each time a page loads. To do that I:

  1. Created a template with a Custom Module with the following Hubl:

{% for row in hubdb_table_rows(675381, “&orderBy=random()&limit=1”) %}
the value for row {{ row.hs_id }} is {{ row.content }}
{% endfor %}

That accomplishes the task of randomizing the result on the first page load. But if I refresh, it doesn’t go retrieve another random record.

Is there a way to do this?

0 Me gusta
3 Respuestas 3
storycollab
Participante | Partner nivel Diamond
Participante | Partner nivel Diamond

Pull Random Record from HubDB Each Time a Page Loads

Is this is still true? Will it only reload random after clearing the cache?

0 Me gusta
cmreinholz
Participante

Pull Random Record from HubDB Each Time a Page Loads

Any way to test it on Chrome on a PC?

Assuming that’s the problem, is there any way to force the page to not load the cached version, or better yet not load the cached piece of the page that contains that code?

0 Me gusta
Derek_Gervais
Exmiembro de HubSpot
Exmiembro de HubSpot

Pull Random Record from HubDB Each Time a Page Loads

Hi @Chadr,

HubL is evaluated when the page is served, and your page is likely cached, so I wouldn’t expect it to return another random row. Does it load a new random row if you refresh without cache (command+shift+R on a mac)?

0 Me gusta