Passing a custom variable to index page template

FMesina
Member

I have this in the blog post page template. Basically it should be able to detect the custom page update date that will be use as sorting date of the post in the index page. I am having trouble passing variable effective_date as value.

~~~

{% set effective_date = content.publish_date %}
{% if module.show_custom_update_date %}
    {% set effective_date = module.updated_date %}
{% endif %}

{% text "display_date" value=effective_date, export_to_template_context=True %}

<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>
~~~

This is what I see in the developer info. I am seeing  "value": "effective_date", instead of the date.

      "type_name": "text",
      "type": "text",
      "name": "module_172082412025471_effective_date",
      "parent_name": "module_172082412025471",
      "label": null,
      "line_number": 6,
      "params": {
        "parent_widget_container": null,
        "tag": "text",
        "type": "text",
        "value": "effective_date",
        "export_to_template_context": true,
        "content_editable_values": [
          "value"
        ],
        "overrideable": true
      },


How can I pass the variable date to index template. Thank you.

0 Upvotes
2 Replies 2
SteveHTM
Key Advisor

@FMesina - I'm not entirely sure I follow the logic of what you are trying to achive here, but my eye is drawn to the statement

{% text "display_date" value=effective_date, export_to_template_context=True %}

which will take the module text field 'display_date' out of the normal evaluation flow and position it as a value settable by the page editor when editing the post. Is that part of the logic you want - or is there anothe reason for the export_to_template designation?

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes
FMesina
Member

Sorry I have not explained it clearly. I would like to set a custom date on a the post that will be use in the index the page for sorting by date.

It will either be the publish date
{% set effective_date = content.publish_date %}

or a custom update date if enabled and set by the user.

{% if module.show_custom_update_date %}
    {% set effective_date = module.updated_date %}
{% endif %}.


Once set in the post. I will use it as sorting reference in the index template.

    {% set sorted_contents = contents|sort(attribute='effective_date', true) %}

    {% for content in sorted_contents %}


How can I have the data available in the index template? 
I am trying to do this line but the value shows as effective_date not the actual date that should be passed.

{% text "display_date" value=effective_date, export_to_template_context=True %}



Thank you.

0 Upvotes