user4103074
user4103074

Reputation: 15

Custom sorting for a blog post using custom update date if enabled

I need to use a custom update date for a blog post and use it for sorting in the list/index page.

I have 3 fields

  1. show_custom_update_date toggling show custom update date on a post
  2. updated_date is for the updated date.
  3. sort_date is to pass the variable data to a module.
{% set effective_date = module.show_custom_update_date ? module.updated_date : content.publish_date %}

{% set module.sort_date = effective_date %}
<p>Sort Date: {{module.sort_date}}</p>

<div class="article-heading-banner">
    <h1 class="article-title">{{content.title}}</h1>
    <p class="article-details"><a href="{{ blog_author_url(group.id, content.blog_post_author.slug) }}">{{ content.blog_post_author.display_name }}</a> | Published &nbsp;{{ content.publish_date | format_date('MMMM dd, yyyy') }}
        {% if module.show_custom_update_date %}
            {% set update_time = content.updated %}
            | Updated {{ module.updated_date | format_date('MMMM dd, yyyy') }}
        {% endif %}
    </p>
</div>

I have tried this on the post page template. I see no data on sort_date when viewing the developer info json of the post. How can I set this via Hubl.

I am expecting to pass date on the the sort_date module.

What is the best way to achieve custom sorting for the index page?

Upvotes: 0

Views: 43

Answers (0)

Related Questions