ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

ExpressionEngine, RSS Feeds & Dates

August 13, 2012 1:04pm

Subscribe [1]
  • #1 / Aug 13, 2012 1:04pm

    superaven

    107 posts

    Hello,

    I’m sort of struggling with a customized RSS feed template I’m trying to create. It’s purpose is to feed into an automated weekly newsletter we send out to members. The goal is to create a feed that displays the top 12 news entries in terms of most views since the last weekly newsletter. I don’t think I’m able to have it gigure out what it sent last, so at the very least, wanted to setup an interval such as top 12 news entries since the previous 12:01am Sunday.

    Anyhow, here’s the code I have (which seems to pull in the top 12 posts of all time.

    Hoping one of you more savvy devs out there can point me in the right direction.

    Thanks in advance.

    {exp:rss:feed channel="news"}
    <?xml version="1.0" encoding="{encoding}"?>
    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
      <title>{exp:xml_encode}SITE NAME HERE{/exp:xml_encode}</title>
      <link>http://www.LINK.com/</link>
      <description>Newsletter RSS Feed</description>
      <dc:language>{channel_language}</dc:language>
      <dc:creator>CREATOR HERE</dc:creator>
      <dc:rights>Copyright {gmt_date format="%Y"}</dc:rights>
      <dc:date>{gmt_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
      <admin:generatorAgent rdf:resource="http://expressionengine.com/" >
      <?php $start_time = $this->EE->localize->decode_date('%Y-%m-%d %H:%i', $this->EE->localize->now - 561600); ?>
      {exp:channel:entries channel="news" rdf="off" start_on="<?php echo $start_time; ?>" limit="12" orderby="view_count_one" dynamic_start="on"}
       {exp:nsm_transplant:body}
        {exp:low_replace find=" "replace="SPACE"}
         <item>
          <title>{title}</title>
          <link>http://www.PATH.com/news/{url_title}</link>
          <guid>{homepage}/news/{url_title}</guid>
          <image>
           {news_thumb}
          </image>
          <thumb>{news_thumb}</thumb>
              
          <description>
          <![CDATA[
           {exp:allow_eecode embed="y"}
             {exp:trunchtml chars="365" inline="..."}
              {news_excerpt}
             {/exp:trunchtml} 
           {/exp:allow_eecode}    
          ]]>
          </description>
          
          <dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
         </item>
        {/exp:low_replace}
       {/exp:nsm_transplant:body}
      {/exp:channel:entries}
     </channel>
    </rss>
    {/exp:rss:feed}
  • #2 / Aug 14, 2012 5:01pm

    Kevin Smith

    4784 posts

    Hi superaven,

    Do you have PHP set to parse on input or output? That difference alone would make a world of difference here. I’d also recommend turning on template debugger to see if the Channel Entries tag that’s being parsed has the right value for the start_on parameter.

  • #3 / Aug 15, 2012 4:50pm

    superaven

    107 posts

    Hello Kevin,

    PHP was disabled (fixed) and parsing is on input. That said, I tested using output as the parsing method and saw no noticeable difference.

    I believe the problem is either with the dates or how its filtering the entries being pulled in. Like I mentioned, it seems to be pulling in top entries (based on views) for all time, as opposed to the last week. Either that or its screwing up on what’s being defined as time right now.

    Any other suggestions? Is there perhaps an addon that might simplify what I’m trying to do here?

    Thanks,

    Allen

  • #4 / Aug 15, 2012 4:59pm

    superaven

    107 posts

    Hello Kevin,

    PHP was disabled (fixed) and parsing is on input. That said, I tested using output as the parsing method and saw no noticeable difference.

    I believe the problem is either with the dates or how its filtering the entries being pulled in. Like I mentioned, it seems to be pulling in top entries (based on views) for all time, as opposed to the last week. Either that or its screwing up on what’s being defined as time right now.

    Any other suggestions? Is there perhaps an addon that might simplify what I’m trying to do here?

    Thanks,

    Allen

    Sorry, my mistake… was working on a duplicate template. Did actually have a big difference. Testing now to see if the dates filtering is working correctly.

    Thanks!

  • #5 / Aug 15, 2012 5:15pm

    superaven

    107 posts

    seems my date filtering is wrong somehow if I’m understanding correctly…

    <?php $start_time = $this->EE->localize->decode_date('%Y-%m-%d %H:%i', $this->EE->localize->now - 561600); ?>
      {exp:channel:entries channel="news" rdf="off" start_on="<?php echo $start_time; ?>" limit="12" orderby="view_count_one" dynamic_start="on"}

    This statement is supposed to figure out what date it is now and then filter out a list of 12 news entries ordered by view count starting from one week ago.

    Anyone know what I’m doing wrong?

    Thanks

  • #6 / Aug 16, 2012 3:43pm

    Kevin Smith

    4784 posts

    Right, what I want us to determine first is if this Channel Entries tag looks like this right before it’s parsed:

    {exp:channel:entries channel="news" rdf="off" start_on="" limit="12" orderby="view_count_one" dynamic_start="on"}

    or like this:

    {exp:channel:entries channel="news" rdf="off" start_on="2012-08-10 02:39" limit="12" orderby="view_count_one" dynamic_start="on"}

    The first means the PHP isn’t being properly inserted into the tag. The second means it is, and should be what you see if you set PHP to enabled and parsed on input.

    Turn on template debugging and you’ll see one line that looks sort of like this:

    (0.066581 / 7.07MB) Tag: {exp:channel:entries channel="news" rdf="off" start_on="2012-08-10 02:39" limit="12" orderby="view_count_one" dynamic_start="on"}

    That shows what EE is actually looking at right before it parses the Channel Entries tag. It’ll let you know whether or not the PHP is being properly inserted into the tag.

  • #7 / Sep 04, 2012 11:25am

    superaven

    107 posts

    Hello Kevin,

    Sorry its taken me so long to return to this. I’ve been caught up putting out other fires and am only just now able to focus on this issue again.

    Anyhow, I was unable to follow your suggestion. Every time I enable the debugging it breaks the xml feed and renders a blank page or one full of errors. I was able to confirm that php is enabled since when its disabled I see the php code in the rendered template. I’ve tried switching the parse method to both output and input. When I set on output, I see the wrong stories load, which points to the date filtering not working correctly. When its set to parse on input, no stories load at all. When I view it with an xml viewer I can see that it presents all the rss data minus the entries themselves, which again points to an issue with my date filtering.

    Any other suggestions?

    Thank you!

  • #8 / Sep 04, 2012 6:15pm

    superaven

    107 posts

    Okay, dumbest mistake ever…

    We installed the NSM Bootstrap and didn’t realize we’d overwritten the view tracking settings. So while focusing on the date filtering, the real problem was that our tracking had gotten disabled unknowingly which threw off everything.

    Wasted so much time on this. Jeez!

    Thanks Kevin for all the help regardless.

    All fixed now.

  • #9 / Sep 05, 2012 5:10pm

    Kevin Smith

    4784 posts

    Oh! Well glad you were able to figure out what was causing it. And thanks for posting back with the solution!

    Let me know if there’s anything else I can do to help.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases