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.

Magpie Plugin with PHP Dates "strtotime()" Error

October 25, 2009 9:44pm

Subscribe [4]
  • #1 / Oct 25, 2009 9:44pm

    jfm

    17 posts

    I recently installed the Magpie RSS/Atom Parser plugin and am using this php code as presented in the EE Wiki to format dates.

    <?php echo date("Y-m-d", strtotime('{pubdate}')); ?>

    All of my feeds seem to parse OK with the exception of one.  In this single RSS feed I’m getting an error that says:

    Notice: strtotime(): Called with empty time parameter

    This link goes to the page with an example of the error.  I searched the Internet and found this Drupal post that looks like a modification to the php code to handle the error.  However, I have little to no understanding of php and don’t know how to implement it.

    A second question, in cases where there is a “-” in the title (or other similar characters), I’m getting odd results within the parsed urls.  This link goes to the page with an example of that problem.

    I appreciate any help that can be provided.

  • #2 / Oct 26, 2009 3:44am

    John Henry Donovan

    12339 posts

    John,
    Can you double check that your PHP is set to Output mode

    Is the Magpie plugin from the latest download of EE you have installed?
    By that I mean, have you been updating the plugins folder as you have upgraded or is this a fresh install?

    A second question, in cases where there is a ā€œ-ā€ in the title (or other similar characters), I’m getting odd results within the parsed urls.  This link goes to the page with an example of that problem.

    You are gonna need to declare a charset for your page. In the header fo your page

    <meta http-equiv="Content-Type" content="text/html; charset={charset}" />
  • #3 / Oct 26, 2009 7:29am

    jfm

    17 posts

    John,

    Thanks - as you said I missed the charset in the header and that worked.

    Concerning the Magpie problem, I do have the PHP for my templates set to output mode.  I’ve tried installing the plugin from the 1.6.8 EE upgrade (build 20090723) and also downloading it directly from the ExpressionEngine site.  I’ve also tried clearing the Magpie cache by deleting all of the files in the folder and have made sure my permissions are set to 777.

  • #4 / Oct 26, 2009 8:40am

    Sue Crocker

    26054 posts

    John, can you post your magpie code here?

  • #5 / Oct 26, 2009 9:07pm

    jfm

    17 posts

    Sue, yes - please see below.  I’ve created a custom field to add a link to the RSS feed for each site.  It’s called “feed_link”.

    {exp:magpie url="{feed_link}" limit="10" refresh="720"}
    <table class="siteindex" cellspacing="0">
    <tr>
    <td class="hed">Posted</td>
    <td class="hed">Recent Entries</td>
    {magpie:items}
    </tr>
    <td width="15%" valign="top"><?php echo date("Y-m-d", strtotime('{pubdate}')); ?></td>
    <td width="85%" valign="top"><a href="http://{magpie:link}">{magpie:title}</a></td>
    </tr>
    {/magpie:items}
    </table>
    {/exp:magpie}
  • #6 / Oct 27, 2009 3:02am

    John Henry Donovan

    12339 posts

    John,

    For that particular feed the variable ‘date’ works fine. Give that a shot.

    <?php echo date("Y-m-d", strtotime('{magpie:date}')); ?>
  • #7 / Oct 28, 2009 9:35am

    jfm

    17 posts

    John,

    Thanks - I gave date variable a try but it doesn’t seem to work.  It’s strange - if I pull in just titles it works fine.  It fails when I bring in dates.  I’m clearing the Magpie cache and retrying with no success. 

    Below is the code that I’m using.  It’s embedded within a weblog:entries tag to provide the functionality that I want. I’m wondering if that’s part of the problem because I’ve read some posts that seem to indicate that the plugin should be used outside of the weblog:entries tag.  However, this type of setup seems to be   working fine on this EE site.

    {exp:magpie url="{feed_link}" limit="10" refresh="720"}
    <table class="siteindex" cellspacing="0">
    <tr>
    <td class="hed">Posted</td>
    <td class="hed">Recent Entries</td>
    {magpie:items}
    </tr>
    <tr>
    <td width="15%" valign="top"><?php echo date("j M", strtotime('{magpie:date}')); ?></td>
    <td width="85%" valign="top"> - <a href="http://{magpie:link}">{magpie:title}</a></td>
    </tr>
    {/magpie:items}
    </table>
    {/exp:magpie}
  • #8 / Oct 28, 2009 11:23am

    Sue Crocker

    26054 posts

    John, can you post a link to the RSS feed you’re attempting to display via Magpie?

  • #9 / Oct 29, 2009 9:21am

    jfm

    17 posts

    Sue, if you go to this page on my site and click on almost any of the links under the “Blogs I Read” heading, you can see the behavior.  Each one of the links will provide the URL of the RSS feed for the referenced site via a table on this page.  Thanks again for your help with this.

  • #10 / Oct 29, 2009 12:14pm

    Sue Crocker

    26054 posts

    The RSS feed for spreadsheetpage.com is coming in with no dates. How are you setting up that particular feed?

    It looks ok to me in Firefox, but when I try and view it with magpie:

    http://eehowto.com/support/xlmagpie/

  • #11 / Oct 30, 2009 9:09am

    jfm

    17 posts

    Sue, I worked with this a little more and I believe I’m seeing two separate issues:

    (1)  I’m able to get spreadsheetpage.com to show dates.  I’m also able to get my site to show dates.  Both just happen to be EE sites.  However, I can’t get dates for the other sites.  The title links work fine for all of the sites.

    I have all of the feeds set up using the following:

    {exp:weblog:entries weblog="resources"}
       {exp:magpie url="{feed_link}" limit="10" refresh="720"}
          <ul>
             {magpie:items}
                <li>{magpie:date} | <a href="http://{magpie:link}">{magpie:title}</a></li>
             {/magpie:items}
          </ul>
       {/exp:magpie}
    {/exp:weblog:entries}

    (2)  When I apply the php code to the date variable as per the EE Wiki, it fails.

    <?php echo date("j M", strtotime('{magpie:date}')); ?>
  • #12 / Oct 31, 2009 4:59pm

    Greg Salt

    3988 posts

    Hi John,

    Can you please modify your code to be this:

    {exp:weblog:entries weblog="resources"}
       {exp:magpie url="{feed_link}" limit="10" refresh="720"}
          <ul>
             {magpie:items}
                <li>{if magpie:date}{magpie:date}{if:else}{magpie:issued}{magpie:modified}{/if} | <a href="http://{magpie:link}">{magpie:title}</a></li>
             {/magpie:items}
          </ul>
       {/exp:magpie}
    {/exp:weblog:entries}

    I just want to check that you are not trying to pull in a mixture of ATOM and RSS feeds. If that were the case then the date variable would not always get populated. The issued and modified variables should be populated by ATOM feeds.

    Cheers

    Greg

  • #13 / Nov 01, 2009 10:14am

    jfm

    17 posts

    Greg, I tried the “if” statement but unfortunately am still getting the same results.

    This is interesting and might help: the latest Magpie version on the EE Plugins downloads site is 1.3.4.  However, the version that comes with EE 1.6.8 is 1.4.

    Two of the sites that I’m getting feeds from are ExpressionEngine sites.  Most of the remaining sites have their feeds going through FeedBurner.  If I pull dates with Magpie Version 1.3.4, I’m able to get dates for FeedBurner feeds but not the EE feeds.  If I pull the dates in Magpie Version 1.4, I’m able to get dates for EE feeds but not the FeedBurner feeds.

    Thanks again for your help with this.

  • #14 / Nov 01, 2009 3:47pm

    Greg Salt

    3988 posts

    Hi John,

    Okay. Please revert to Magpie version 1.4 and then create a new template and place just the Magpie code in it hardcoding the feed links. Lets test one tag per feed like this:

    {exp:magpie url="http://domain.com/feed" limit="10" refresh="720"}
          <ul>
             {magpie:items}
                <li>{magpie:date} | <a href="http://{magpie:link}">{magpie:title}</a></li>
             {/magpie:items}
          </ul>
      {/exp:magpie}

    Make sure that you put at least one tag for each type of feed you have (EE & Feedburner).

    Cheers

    Greg

  • #15 / Nov 01, 2009 7:23pm

    jfm

    17 posts

    Greg, I’ve linked four stand-alone templates each of which contains a single hardcoded feed.  I’ve loaded Magpie version 1.4 and cleared the Magpie cache.

    Please see this page for examples.  Thanks again.

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

ExpressionEngine News!

#eecms, #events, #releases