Please note: I did not develop this module
video demostration
*full block of code at the end
————————————
I am working on troubleshooting a custom blog post module that I am unable to edit or publish. Though the module is currently being used on the site.
Within the design manager I am getting a few error messages but no real insight into what the specific issue is:
1:0 DisabledException: ‘module’ is disabled in the context
271:1 datetimeformat filter called with null datetime
From trying different troubleshooting methods I have been able to identify what I believe the two bits of problematic code are
Code
{% set min_date = (dates|last).publish_date|datetimeformat(“%m/%d/%Y”) %}
{% set max_date = (dates|first).publish_date|datetimeformat(“%m/%d/%Y”) %}
HubSpot error message
271:1 datetimeformat filter called with null datetime
I thought maybe setting a default date of August 7th, 2020 [first published blog post] would solve the issue but it did not.
I have been reading through different posts in the forum on converting datetimeformat strings to see if there is anything wrong with the two lines of code but I cannot identify what the error might be.
I made a video demonstration so it is easier to explain the error.
Any thoughts or ideas would be much appreciated.
video demostration
————————————
Full Block of code
{% set curr_year = request.query_dict[module.cssid ~ “Year”] %}
{% set curr_month = request.query_dict[module.cssid ~ “Month”] %}
{% set curr_day = request.query_dict[module.cssid ~ “Day”] %}
{% set curr_term = request.query_dict[module.cssid ~ “Term”] %}
{% set curr_tag = request.query_dict[module.cssid ~ “Tag”] %}
{% set curr_author = request.query_dict[module.cssid ~ “Author”] %}
{% set dates = posts|selectattr(“publish_date”, “truthy”, true)|sort(attribute=“publish_date”) %}
{% set min_date = (dates|last).publish_date|datetimeformat(“%m/%d/%Y”) %}
{% set max_date = (dates|first).publish_date|datetimeformat(“%m/%d/%Y”) %}
{% set min_year = min_date|split(“/”)|last|int %}
{% set max_year = max_date|split(“/”)|last|int %}
{% set filteredPosts = posts %}
{% if curr_year and curr_year != “All” %}
{% set temp = [] %}
{% for post in filteredPosts %}
{% set year = post.publish_date|datetimeformat(“%Y”)|int %}
{% if year|int == curr_year|int %}
{% do temp.append(post) %}
{% endif %}
{% endfor %}
{% set filteredPosts = temp %}
{% endif %}
{% if curr_month and curr_month != “All” %}
{% set temp = [] %}
{% for post in filteredPosts %}
{% set month = post.publish_date|datetimeformat(“%m”)|int %}
{% if month|int == curr_month|int %}
{% do temp.append(post) %}
{% endif %}
{% endfor %}
{% set filteredPosts = temp %}
{% endif %}
{% if curr_day and curr_day != “All” %}
{% set temp = [] %}
{% for post in filteredPosts %}
{% set day = post.publish_date|datetimeformat(“%d”)|int %}
{% if day|int == curr_day|int %}
{% do temp.append(post) %}
{% endif %}
{% endfor %}
{% set filteredPosts = temp %}
{% endif %}
{% if curr_term and curr_term != “” %}
{% set temp = [] %}
{% set searchTerm = curr_term|urldecode %}
{% for post in filteredPosts %}
{% set body = post.post_body %}
{% if searchTerm in body %}
{% do temp.append(post) %}
{% endif %}
{% endfor %}
{% set filteredPosts = temp %}
{% endif %}
{% if curr_tag and curr_tag != “All” %}
{% set temp = [] %}
{% for post in filteredPosts %}
{% set tags = post.tag_list %}
{% set tempTags = [] %}
{% for tag in tags %}
{% do tempTags.append(tag.id) %}
{% endfor %}
{% set tags = tempTags %}
{% if curr_tag in tags %}
{% do temp.append(post) %}
{% endif %}
{% endfor %}
{% set filteredPosts = temp %}
{% endif %}
{% if curr_author and curr_author != “All” %}
{% set temp = [] %}
{% for post in filteredPosts %}
{% if post.blog_author_id == curr_author %}
{% do temp.append(post) %}
{% endif %}
{% endfor %}
{% set filteredPosts = temp %}
{% endif %}
{% set posts = filteredPosts %}
{% set num_posts = posts|length %}
{% set last_page_num = num_posts / limit %}
{% if “.” in (last_page_num ~ “”) %}
{% set decimals = (last_page_num ~ “”)|split(“.”)|last|int %}
{% if decimals > 0 %}
{% set last_page_num = (last_page_num ~ “”)|split(“.”)|first|int + 1 %}
{% endif %}
{% endif %}
{% set namesMonths = [
“January”,
“February”,
“March”,
“April”,
“May”,
“June”,
“July”,
“August”,
“September”,
“October”,
“November”,
“December”
] %}
{% set num_posts = posts|length %}
{% set first_page_num = 1 %}
{% set last_page_num = num_posts / limit %}
{% if “.” in (last_page_num ~ “”) %}
{% set decimals = (last_page_num ~ “”)|split(“.”)|last|int %}
{% if decimals > 0 %}
{% set last_page_num = (last_page_num ~ “”)|split(“.”)|first|int + 1 %}
{% endif %}
{% endif %}