nimish79

Topic: invalid feed - W3C Date Format

If you try to validate the feed, then you'd realize that there is a problem with the specified date format. Check http://feedvalidator.org/check.cgi?url= … rss/toate/ for example and you'll see what I am talking about. Those who are tech savvy could please look into this and tell the users about the necessary changes in the class.feed file.

hobo

Re: invalid feed - W3C Date Format

There is a small typo in  _templates/rss.tpl, the word "toate" needs to be replaced with word "all".

Find (line 9):

<li><a href="{$BASE_URL}rss/toate/">{$translations.rss.all_categories}</a></li>

Replace with:

<li><a href="{$BASE_URL}rss/all/">{$translations.rss.all_categories}</a></li>

nht48823

Re: invalid feed - W3C Date Format

I get the following error when i validate

"This feed does not validate.

line 25, column 30: dc:date must be an W3CDTF date: 2009-04-17 09:25:59 (8 occurrences) [help]"

I Replace with:

<li><a href="{$BASE_URL}rss/all/">{$translations.rss.all_categories}</a></li>
no luck.

lxer

Re: invalid feed - W3C Date Format

it should look like this:

  2009-04-17T09:25:59+01:00

nht48823

Re: invalid feed - W3C Date Format

how do i go about making it look like that?

lxer

Re: invalid feed - W3C Date Format

in the file class.Feed.php  change

change this (line 69) :
   $properties['dc:date'] = date('d-m-Y');
to
   $properties['dc:date'] =  date("c");

evertsemeijn

Re: invalid feed - W3C Date Format

Great tip, but according to the feed validator that's still not a valid dateformat. I commented

Code:
properties['dc:date'] = $job['mysql_date'];

so that it's not being written.

Still waiting for THE solution wink

Member of Jobberbase Development Team - Templates/Usability :: Looking for installation and/or custom design? :: Beautiful Wordpress themes

lxer

Re: invalid feed - W3C Date Format

... and
at line 122 :

Code:

 $properties['dc:date'] = str_replace(" ","T",$job['mysql_date'])
                                                .substr_replace(date("O"),":",3,0);

Last edited by lxer (2009-05-10 09:29:21)

nht48823

Re: invalid feed - W3C Date Format

no luck

lxer

Re: invalid feed - W3C Date Format

works for me.
so, be specific, please

nht48823

Re: invalid feed - W3C Date Format

I get the following error:

"This feed does not validate.

line 19, column 30: dc:date must be an W3CDTF date: 2009-05-12 19:19:09 (2 occurrences) [help]"

lxer

Re: invalid feed - W3C Date Format

so you have 2 adds in that feed?
and did you actually replace $properties['dc:date'] = $job['mysql_date'] with 

Code:
 $properties['dc:date'] = str_replace(" ","T",$job['mysql_date'])
                                                .substr_replace(date("O"),":",3,0);

?
looks like you didn't

nht48823

Re: invalid feed - W3C Date Format

Here are the steps:
1._templates/rss.tpl: Replace "toate" with "all" 
2. $properties['dc:date'] = date('d-m-Y'); : replace with "c"
$properties['dc:date'] = $job['mysql_date'] replace with
3. class.Feed.php" $properties['dc:date'] = str_replace(" ","T",$job['mysql_date'])
                                                .substr_replace(date("O"),":",3,0);

Thanks for your help!

Still waiting for THE solution

lxer

Re: invalid feed - W3C Date Format

i don't get it, since it works great at my site.

could you provide a link or put your rss on pastie.org ?

hobo

Re: invalid feed - W3C Date Format

Works fine for me too.
Thanx Lxer!

@nht48823
Try testing the feed with jobs in it.

Last edited by hobo (2009-05-13 21:19:16)

nht48823

Re: invalid feed - W3C Date Format

sure, http://inerc.com/blog/
as you can see the date is not correct on the post. the feed is from http://inerc.com/

hobo

Re: invalid feed - W3C Date Format

@nht48823
You also have issues on your jobberbase because of invalid characters in category url field, there should be no forward slashes in the url field, and also no spaces (in admin>categories). Dashes and underscores are ok.
Your jobberbase rss feed validates fine and there is no 1969 in your "rss/all", could be wordpress issue, google "December 31st, 1969 mysql wordpress rss", there are many with same issue.

lxer

Re: invalid feed - W3C Date Format

...wordpress??
wtf?

nht48823

Re: invalid feed - W3C Date Format

Thanks for all of your help.... here's the final file version that works:

<?php
/**
* jobber job board platform
*
* @author     Filip C.T.E. <http://www.filipcte.ro> <me@filipcte.ro>
* @license    You are free to edit and use this work, but it would be nice if you always referenced the original author wink
*             (see license.txt).
*
* Feed class displays RSS feeds
*/

require_once 'class.XmlWriter.php';
require_once 'class.RssWriter.php';

class Feed
{
    var $mCategoryId = false;
    var $mCategoryVarName = false;
   
    function __construct($category = false)
    {
        global $db;
        if ($category != 'all')
        {
            $sql = 'SELECT id
                           FROM categories
                           WHERE var_name = "' . $category . '"';
            $result = $db->query($sql);
            $row = $result->fetch_assoc();
            $this->mCategoryId = $row['id'];
            $this->mCategoryVarName = $category;
            return 1;
        }
        else if ($category == 'all')
        {
            $this->mCategoryId = 'all';
        }
        else
        {
            return 0;
        }
    }
   
    // Display a feed
    public function Display()
    {
        global $db;
        $rss_writer_object = new rss_writer_class;
        $rss_writer_object->specification = '1.0';
        $rss_writer_object->about = BASE_URL . 'rss.xml';
        $rss_writer_object->rssnamespaces['dc']='http://purl.org/dc/elements/1.1/';

        $properties = array();
        if ($this->mCategoryId == 'all')
        {
            $properties['description'] = 'Latest jobs';
        }
        else
        {
            $properties['description'] = 'Latest jobs for ' . ucwords($this->mCategoryVarName);
        }
        $properties['link'] = BASE_URL;
        $properties['title'] = SITE_NAME;
        $properties['dc:date'] = date('c');
        $rss_writer_object->addchannel($properties);

        $count = 0;

        $jobb = new Job();
        if ($this->mCategoryId == 'all')
        {
            $jobs = $jobb->GetJobs(0, 0, 0, 0, 0, true);
        }
        else
        {
            $jobs = $jobb->GetJobs(0, $this->mCategoryId, 0, 0, 0, true);
        }
        foreach ($jobs as $job)
        {
            $count++;
            if ($count > 10)
            {
                break;
            }
           
            $properties=array(); 
            $properties['description'] = '<strong>Location:</strong> ' . $job['location'] . '<br />';
            if ($job['url'] != '' && $job['url'] != 'http://')
            {
                $properties['description'] .= '<strong>URL:</strong> <a href="' . $job['url'] . '">' . $job['url'] . '</a><br /><br />';
            }
            $textile = new Textile();
            $job['description'] = $textile->TextileThis($job['description']);
            $properties['description'] .= '<strong>Description:</strong><br />' . $job['description'] . '<br /><br />';
            $properties['description'] .= '<a href="' . BASE_URL . 'job/' . $job['id'] . '/' . $job['url_title'] . '/' . '">Apply to this job</a><br />';
            $properties['link'] = BASE_URL . 'job/' . $job['id'] . '/' . $job['url_title'] . '/';

            if ($job['type_id'] == JOBTYPE_FULLTIME)
            {
                $type = '[full-time]';
            }
            else if ($job['type_id'] == JOBTYPE_PARTTIME)
            {
                $type = '[part-time]';
            }
            else if ($job['type_id'] == JOBTYPE_FREELANCE)
            {
                $type = '[freelance]';
            }
            $properties['title'] = $type . ' ' . $job['title'] . ' at ' . $job['company'];
            $properties['dc:date'] = str_replace(" ","T",$job['mysql_date'])
                                                .substr_replace(date("O"),":",3,0);
            $rss_writer_object->additem($properties);
        }
        if (empty($jobs))
        {
            $properties=array(); 
            $properties['description'] = ' ';
            $properties['description'] .= ' ';
            $properties['link'] = ' ';
            $properties['title'] = ' ';
            $properties['dc:date'] = str_replace(" ","T",$job['mysql_date'])
                                                .substr_replace(date("O"),":",3,0);
            $rss_writer_object->additem($properties);
        }

        if($rss_writer_object->writerss($output))
        {
            header('Content-Type: text/xml; charset="utf-8"');
            header('Content-Length: '.strval(strlen($output)));
            echo $output;
        }
        else
        {
            //header('Content-Type: text/plain');
            //echo ('Error: '.$rss_writer_object->error);
        }
    }

}
?>

jobnavy

Re: invalid feed - W3C Date Format

These three steps work for me. Thanks guy!

hobo wrote:

There is a small typo in  _templates/rss.tpl, the word "toate" needs to be replaced with word "all".

Find (line 9):

<li><a href="{$BASE_URL}rss/toate/">{$translations.rss.all_categories}</a></li>

Replace with:

<li><a href="{$BASE_URL}rss/all/">{$translations.rss.all_categories}</a></li>

lxer wrote:


in the file class.Feed.php  change

change this (line 69) :
   $properties['dc:date'] = date('d-m-Y');
to
   $properties['dc:date'] =  date("c");

evertsemeijn wrote:


Great tip, but according to the feed validator that's still not a valid dateformat. I commented

Code:
properties['dc:date'] = $job['mysql_date'];