Custom / Special Modifcations

The general code we offer will not meet every need and we have provided suggestions to some requests for features that we have not incorporated into the general version of the script.

Adding UTF-8 Support

I saw UTF-8 support at your build page and I need help about instaling it at my instalation of Feed2JS on my server. I need it because of language of feeds I intend to use.

As of March 28, 2005, this is now built into our distributions of Feed2JS.

Users seeing strange character substitutions in the display of feeds should try UTF-8 encoding (this also requires an editing of the HTML for the page containing the cut and paste javascript code).

Limiting Feeds to a Domain

I have installed Feed2JS on my own server, but I do not want others to use it to syndicate feeds form other sites. How can I restrict it to publish feeds from just my site?

As of version 2.21, this is built in feature (thanks for contributer tero p). Look in the feed2js_config.php script for this section, which as the default, does not restrict any URLs

// Restrict RSS url to domain
// Example: => allows and
// Example: => allows and

// remove the comment here to activate url restriction
//$restrict_url = "";

// comment out this line to activate url restriction

Modify it to use the domain you want to limit it:

// Restrict RSS url to domain
// Example: => allows and
// Example: => allows and

// remove the comment here to activate url restriction
$restrict_url = "";

// comment out this line to activate url restriction

For an alternative, and perhaps simpler approach, see D'Arcy Norman's method of restricting use of Feed2JS via checking the referring URL in an htaccess file.

Making JavaScript Valid XHTML

One comment, though. The javascript that is generated by default doesn't comply with the XHTML 1.0 Transitional (using the W3C validation service). To make it do so, only a simple change is required.

As of April 6, 2006 this is built in to the current Feed2JS build a feed form.

Hyperlinks in Descriptions

Is there a way of preserving links from the original posts in the resulting javascript feed? (ie. links from within the post, not the post title itself.

Note: As of Dec 2004, this is now a feature of Feed2JS, the ability to set html=a to force display of all HTML in feed items. The notes below are for older versions of our script.

You can do this by changing the line that reads:

$my_blurb = strip_tags ($item['summary']);

to read

$my_blurb = $item['summary'];

which takes away the feature of stripping out html from the description. The problem with doing this on a wider scale is that there are all kinds of HTML thrown into feeds, and when I made the change with a sample provided, it ended up with an unclosed <i> tag that messed everything else up. But if you have a controlled set of feed outputs, you might be able to safely do this locally.

This can be done but the risk is for feeds that do not close tags (often feeds are truncated by the publishing software, so your mileage may vary.

Remove Links to Items

How simple/difficult would it be to remove the link back to the original post from the heading in the resulting javascript feed? I realize I could accomplish this by hiding it through CSS, but I would still like to have the title, but just not as a link.

Change the line that reads:

$str.= "document.write('<li class=\"rss-item\">
<a class=\"rss-item\" href=\"" . trim($my_url) . 
"\" title=\"$title_str\"". $target_window . '>' . 
$my_title . "</a><br />');\n";


$str.= "document.write('<li class=\"rss-item\">" . $my_title);\n";

which removes the link tags.

Show us your love, post a badge

Brian Teller
is keeping Feed2JS alive, thanks Brian (applause)

Digital Signage Report

github project site

Feed2JS is fueled by Magpie RSS