Sort Your HubDB Data by Latest Additions Using &orderBy in HubL

Sorting HubDB Data by Most Recently Added with HubL and the &orderBy Parameter
Sorting HubDB data by the date it was added can be a bit tricky due to the mixed verbiage and unclear documentation surrounding the query parameters. However, it’s actually possible to easily sort HubDB data by most recently added using HubL and the &orderBy parameter.
To do so, you need to use a prefix and a minus sign(-) to reverse the order of the results. Here’s an example of how to use this technique in HubL:
1 2 3 |
{% for row in hubdb_table_rows('name_of_hubdb', '&orderBy=-hs_created_at') %} <!-- Your code here --> {% endfor %} |
This code will sort the rows in the “name_of_hubdb” table by the hs_created_at field in descending order (i.e., from newest to oldest). Note that the prefix “&” is used to separate the “name_of_hubdb” parameter from the “&orderBy” parameter.
Good luck with your HubDB sorting, and don’t hesitate to pass this tip along to others who may find it helpful!
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]