<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HUBL limiting dates in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309616#M14854</link>
    <description>&lt;P&gt;Both worked great, but I went with the 2nd suggestion since there was concern about the first showing less than 3 posts. The styling changed a bit to match our main website on a different platform, but otherwise was a straight copy and paste. Appreciated the notes to understand what each step was doing. Thanks so much for the help!!!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jan 2020 15:16:46 GMT</pubDate>
    <dc:creator>mkarsten</dc:creator>
    <dc:date>2020-01-02T15:16:46Z</dc:date>
    <item>
      <title>HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/307868#M14729</link>
      <description>&lt;P&gt;I'm working on a blog home landing page using a custom module with HUBL. The basic Hubl is working to pull the 3 most popular blog posts:&lt;/P&gt;&lt;P&gt;&amp;lt;div class="popular-post"&amp;gt;&lt;BR /&gt;{% set pop_posts = blog_popular_posts('default', 3) %} {% for pop_post in pop_posts %}&lt;BR /&gt;&amp;lt;p style="font-size: 16px;"&amp;gt;&amp;lt;img src="{{ pop_post.featured_image }}" width="150" style="padding-right: 15px"&amp;gt;&lt;BR /&gt;&amp;lt;a href="{{pop_post.url}}"&amp;gt;&lt;BR /&gt;{{ pop_post.name }}&lt;BR /&gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need to limit it to only include blogs published within the last year from the current date. I started with an if statement, but then found some filtering info, so I've been playing with:&lt;/P&gt;&lt;P&gt;{% set date = 'null' %}&lt;BR /&gt;{{date}}&lt;BR /&gt;{{date|minus_time(1, 'years') }}&lt;/P&gt;&lt;P&gt;But it's not working, still pulling all time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions greatly appreciated!&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 21:44:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/307868#M14729</guid>
      <dc:creator>mkarsten</dc:creator>
      <dc:date>2019-12-16T21:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/308713#M14785</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/6699"&gt;@mkarsten&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I will tag a few of our experts to learn from them.&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hey&amp;nbsp;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/91608"&gt;@alyssamwilie&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/81734"&gt;@willsmith&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;&amp;nbsp;could you please share your knowledge with&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/6699"&gt;@mkarsten&lt;/a&gt;?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you &amp;amp; Happy Holidays&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sharon&amp;nbsp;&lt;IMG class="emoticon emoticon-smileyhappy" src="https://community.hubspot.com/i/smilies/16x16_smiley-happy.png" border="0" alt="Emoticono feliz" title="Emoticono feliz" /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 10:09:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/308713#M14785</guid>
      <dc:creator>sharonlicari</dc:creator>
      <dc:date>2019-12-20T10:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/308760#M14790</link>
      <description>&lt;P&gt;Thanks for passing it on!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 14:36:18 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/308760#M14790</guid>
      <dc:creator>mkarsten</dc:creator>
      <dc:date>2019-12-20T14:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309472#M14843</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/6699"&gt;@mkarsten&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you try something like this?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;div class="popular-post"&amp;gt;
  {% set pop_posts = blog_recent_posts('default', 3) %}
  {% set today =  local_dt %} {# get and assign current date #}
  {% for pop_post in pop_posts %}

  {% set postDate = pop_post.publish_date %} {# get and assign post publish date per loop #}
  {% set yearDif = today|between_times(postDate, 'years') %} {# compare the date objects to the year - outputs an integer #}
  
    {% if yearDif &amp;lt;= 0 %} {# if the the yearDif is less than or equal to 0, print #}

    &amp;lt;p style="font-size: 16px;"&amp;gt;
      &amp;lt;img src="{{ pop_post.featured_image }}" width="150" style="padding-right: 15px"&amp;gt;
      &amp;lt;a href="{{pop_post.url}}"&amp;gt;
        {{ pop_post.name }}
      &amp;lt;/a&amp;gt;
    &amp;lt;/p&amp;gt;
  
    {% endif %} 

  {% endfor %}
&amp;lt;/div&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;I just noticed that this could very well return less than 3 resualts. I will continue to explore the most effieicent option.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:02:26 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309472#M14843</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2019-12-31T15:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309481#M14844</link>
      <description>&lt;P&gt;That might work tho.... if they want to limit it to the past year, they might have to accept that there could be less than 3 posts.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:19:56 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309481#M14844</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-31T15:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309484#M14845</link>
      <description>&lt;P&gt;What about increasing our dictionery and limiting the printed content that matches the year criteria?&lt;/P&gt;
&lt;PRE&gt;{% set pop_posts = blog_recent_posts('default', 36) %} {# assuming you're publishing 3 posts a month - could be less to reduce load #}
{% set today =  local_dt %} {# get and assign current date #}
{% set resCount = 0 %}

&amp;lt;div class="popular-post"&amp;gt;
  {% for pop_post in pop_posts %}

    {% set postDate = pop_post.publish_date %} {# get and assign post publish date per loop #}
    {% set yearDif = today|between_times(postDate, 'years') %} {# compare the date objects to the year - outputs an integer #}

    {% if yearDif &amp;lt;= 0 %} {# if the the yearDif is less than or equal to 0, print #}
      {% if resCount &amp;lt; 3 %} {# if we've matched 3 we can ignore the rest #}
        {% set resCount = resCount + 1 %} {# resCount++ #}
        &amp;lt;p style="font-size: 16px;"&amp;gt;
          &amp;lt;img src="{{ pop_post.featured_image }}" width="150" style="padding-right: 15px"&amp;gt;
          &amp;lt;a href="{{pop_post.url}}"&amp;gt;
            {{ pop_post.name }}
          &amp;lt;/a&amp;gt;
        &amp;lt;/p&amp;gt;
      {% endif %} 
    {% endif %} 

  {% endfor %}
&amp;lt;/div&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:42:55 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309484#M14845</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2019-12-31T15:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309616#M14854</link>
      <description>&lt;P&gt;Both worked great, but I went with the 2nd suggestion since there was concern about the first showing less than 3 posts. The styling changed a bit to match our main website on a different platform, but otherwise was a straight copy and paste. Appreciated the notes to understand what each step was doing. Thanks so much for the help!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 15:16:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309616#M14854</guid>
      <dc:creator>mkarsten</dc:creator>
      <dc:date>2020-01-02T15:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309619#M14855</link>
      <description>&lt;P&gt;I spoke too soon.:( When I went to double check the blog posts the automation is pulling, it is bringing up the 3 most recent instead of the 3 most popular. When I change the first set to {% set pop_posts = blog_popular_posts('default', 36) %} it then pulls all time instead of only from the last year. Any other suggestions?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 15:28:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309619#M14855</guid>
      <dc:creator>mkarsten</dc:creator>
      <dc:date>2020-01-02T15:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309626#M14856</link>
      <description>&lt;P&gt;I missed that the between_times will return the integer with the value of the difference. So on posts older than 1 year it returns -1 and not 1 like I assumed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Fix:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Change the operator in the first for loop to be "&amp;gt;=" rather than "&amp;lt;=".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;{% set pop_posts = blog_popular_posts('default', 36) %} {# assuming you're publishing 3 posts a month - could be less to reduce load #}
{% set today =  local_dt %} {# get and assign current date #}
{% set resCount = 0 %}

&amp;lt;div class="popular-post"&amp;gt;
  {% for pop_post in pop_posts %}

    {% set postDate = pop_post.publish_date %} {# get and assign post publish date per loop #}
    {% set yearDif = today|between_times(postDate, 'years') %} {# compare the date objects to the year - outputs an integer #}

    &lt;U&gt;&lt;STRONG&gt;{% if yearDif &amp;gt;= 0 %}&lt;/STRONG&gt;&lt;/U&gt; {# if the the yearDif is less than or equal to 0, print #}
      {% if resCount &amp;lt; 3 %} {# if we've matched 3 we can ignore the rest #}
        {% set resCount = resCount + 1 %} {# resCount++ #}
        &amp;lt;p style="font-size: 16px;"&amp;gt;
          &amp;lt;img src="{{ pop_post.featured_image }}" width="150" style="padding-right: 15px"&amp;gt;
          &amp;lt;a href="{{pop_post.url}}"&amp;gt;
            {{ pop_post.name }}
          &amp;lt;/a&amp;gt;
        &amp;lt;/p&amp;gt;
      {% endif %} 
    {% endif %} 

  {% endfor %}
&amp;lt;/div&amp;gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jan 2020 16:00:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309626#M14856</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2020-01-02T16:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309628#M14857</link>
      <description>&lt;P&gt;Checked the stats and that did the trick! Thanks for the quick response.:)&lt;/P&gt;&lt;P&gt;PS: The order looks correct.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 16:10:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309628#M14857</guid>
      <dc:creator>mkarsten</dc:creator>
      <dc:date>2020-01-02T16:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: HUBL limiting dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309629#M14858</link>
      <description>&lt;P&gt;Another note that just occured to me. I'm not sure what order the &lt;STRONG&gt;blog_popular_posts('default', 36) &lt;/STRONG&gt;request will return. It might be safe to assume that they'll come in as most – least&amp;nbsp;popular relatively. So they won't be in chronological order if thats the case, but that &lt;STRONG&gt;if&lt;/STRONG&gt; statement should still olny print values of a year or less.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If thats an issue we will have to look into reordering the &lt;EM&gt;pop_posts &lt;/EM&gt;before running it through the printing logic.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 16:49:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HUBL-limiting-dates/m-p/309629#M14858</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2020-01-02T16:49:48Z</dc:date>
    </item>
  </channel>
</rss>

