CMS Development

Manobyte
Contributor | Diamond Partner
Contributor | Diamond Partner

Hubl |round token "Error:Invalid input for 'round': input with value 'NaN' must be a number"

So I bult a little thing that counts hubDB rows and then devides that by the number of items I wish to show per "page" and then rounds up to get the number of pages. And this worked just fine untill yesterday when I needed to update something in the module and it would not let me save because "Error:Invalid input for 'round': input with value 'NaN' must be a number".

I though maybe something happened to the variable so I told it to print the variable I was trying to round and it was a number. I tryed putting it in an if statement chacking the it was >= 1, to make sure it was a number, but it still would not let me save it. Here is my Hubl;

{% set allposts = hubdb_table_rows(dynamic_page_hubdb_table_id)|length %}

{% set pages = allposts / module.items_per_page %}

{% set pagesround = pages|round(0, 'ceil') %}

 

Update:  While I was typing this out I actually figured it out, but thought I would post it anyway incase someone else come accross the same issue.

Solution: It turns out that the "module.items_per_page" was what was causing the error. When I replaced this with a static number rather then a veriable it let me publish the module. I did however want to be able to keep using the variable so people could change the "items per page" so I changed the if statement I mentiioned before to check that the module.items_per_page was >= 1 and everything is back to working.

 

{% if module.items_per_page >= 1 %}
{% set pagesround = pages|round(0, 'ceil') %}
{% endif %}

1 Reply 1
jennysowyrda
Community Manager
Community Manager

Hubl |round token "Error:Invalid input for 'round': input with value 'NaN' must be a number"

Thank you for sharing @Manobyte! 🙂 

0 Upvotes