Jump to content


Photo
- - - - -

Site w/ outbound RSS


  • Please log in to reply
12 replies to this topic

#1 jeffhope

jeffhope

    Member

  • Members
  • PipPip
  • 15 posts

Posted 02 September 2005 - 04:58 AM

Hi,

I've just converted http://www.centraluccdallas.org over to Soholaunch, & added a few goodies.

Of note is that it has outbound RSS feeds from the news & sermons blogs, and an outbound RSS feed from the calendar. These were accomplished with some database info that Cameron provided in another thread. The RSS links are under the XML icon in the lower part of the right hand column.

In addition, I used the site_pages table to create a very basic Google Sitemap, linked in that same area.

On the front page is a custom-coded display of blog & calendar data, and at the very bottom of the front page is a display of an inbound RSS news feed that originates from another site. Although I'm using my own application to do this, it can also be done easily with either of these free applications:

http://magpierss.sourceforge.net/ (Magpie)
http://www.geckotribe.com/rss/ (Carp)

I love working with Soholaunch so far - it's going to save me untold time in creating and maintaining client sites :D

Jeff

#2 sinclair

sinclair

    Senior Member

  • Members
  • 193 posts

Posted 02 September 2005 - 04:28 PM

I have thinking there had to be a way to display an RSS feed, but had not found it. Thank you for sharing those sources.

#3 Cameron Allen

Cameron Allen

    Senior Member

  • Administrators
  • 671 posts

Posted 07 September 2005 - 09:25 PM

It is really interesting seeing outbound RSS feeds integrated into the blog manager. Well done Jeff! =]. I especially like how you use them to display upcoming calendar events on the home page. I don't know allot about RSS feeds, but after seeing what Jeff has done, I feel as though I have been missing out! Its like a dynamic database for search engines, with the capability to easily remotely display anything!
Cameron Allen
Director of Technical Services
Soholaunch.com Inc ...Website Building Made Easy

#4 Bradnjxn

Bradnjxn

    Advanced Member

  • Members
  • PipPipPip
  • 90 posts

Posted 08 September 2005 - 10:15 PM

Jeff - I'd love to do my calendar like that. How did you do it?

#5 jeffhope

jeffhope

    Member

  • Members
  • PipPip
  • 15 posts

Posted 09 September 2005 - 03:48 AM

Bradnjxn,

I'm not clear - were you referring to the list of events on the front page, or the RSS feed of the calendar of events?

Let me know & I'll post the code here.

Jeff

#6 Bradnjxn

Bradnjxn

    Advanced Member

  • Members
  • PipPipPip
  • 90 posts

Posted 09 September 2005 - 02:03 PM

Jeff,

I was referring to the list of events. But I love the RSS feed too!

#7 jeffhope

jeffhope

    Member

  • Members
  • PipPip
  • 15 posts

Posted 13 September 2005 - 03:05 AM

Here's the code to pull data from your calendar and display it in tabular format:

1. Create a file to display the data. This one is custom_news.inc:

<?php
// displays calendar event data in tabular format
// determine today's date, as we only want events dated today or after
$today = date('Y-m-d');

echo "<div align=\"left\" style=\"font-size: 12px;\">";

// change the heading as needed
echo '<h3>Your Heading Here</h3>';

// sql statement selects 10 events dated current date or in the future, 
// and sorted by nearest event to current date first
$result = mysql_query("SELECT * FROM calendar_events WHERE EVENT_DATE >= '" . $today . "' ORDER BY EVENT_DATE limit 10");
// loop through database results from query
while ($row = mysql_fetch_array($result)) {
   echo '<b>' . $row[EVENT_DATE] . ' - ' . $row[EVENT_TITLE] . '</b><br>' . 
// displays first 150 characters of event description
   substr($row[EVENT_DETAILS],0,150) . '<br><br>';
}

echo "</div>";
?>

2. Upload the file to your root directory. Then add custom script file to whatever page you want, choosing the file you just uploaded.

When you display the page where you added the custom script, you should see your next 10 (or whatever you set) events.

Jeff

#8 jeffhope

jeffhope

    Member

  • Members
  • PipPip
  • 15 posts

Posted 13 September 2005 - 03:23 AM

Here's the code to generate an RSS feed. The example is for your events calendar, but it can work with blogs, etc., too, if appropriate table and row names are changed.

1. Create a file to connect to the database - this one is called xconnect.php

<?
$dbmsg =  "<P>The MySQL database is temporarily unavailable. Error: ";

$db_server = 'localhost';
$db_name = 'your_database_name';
$db_un = 'your_dataase_username';
$db_pw = 'your_password';

$dbcnx = @mysql_connect($db_server, $db_un , $db_pw);
if (!$dbcnx) {
   echo($dbmsg . mysql_error());
  }
mysql_select_db($db_name) or die("Unable to connect to the database");

?>

2. Create a PHP file to extract the data. This one is called rss.php:

<?php

// connect to the database
@include('xconnect.php');

// we only want events for today & after so define today's date
$today = date('Y-m-d');

// define sql query, limit to 10 events dated today or after, 
// and sorted by nearest event date first
$result = mysql_query("SELECT * FROM calendar_events WHERE EVENT_DATE >= '" . $today . "' ORDER BY EVENT_DATE limit 10");

// loop through sql query results
while ($row = mysql_fetch_array($result)) {

// define data for current row, we want to send visitors to the Events page
// when they click on one of our feed items
  $title = $row[EVENT_DATE] . ' - ' . $row[EVENT_TITLE];
  $url = 'http://www.yourdomain.com/index.php?pr=Events';
// show first 250 characters of event description in this item
  $desc = strip_tags(substr($row[EVENT_DETAILS],0,250));

// remove some characters as they cause problems in RSS feeds
  $desc = str_replace("&",'',$desc);

// create the XML structure for this row, adding on to previous rows
// and using the fields defined above
  $items     .= "     <item>\n";
  $items     .= "       <title>$title</title>\n";
  $items     .= "       <link>$url</link>\n";
  $items     .= "       <description>$desc</description>\n";
  $items     .= "     </item>\n";

}

// must output xml header
header("Content-type: text/xml; charset=iso-8859-1");

// create heading & channel data for feed
$output .= "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
$output .= "<!-- generator=\"YourDomain.com\" -->\n";
$output .= "<!DOCTYPE rss >\n";
$output .= "<rss version=\"0.92\">\n";
$output .= "  <channel>\n";
$output .= "    <title>Your Site Here " . ucwords($_GET['feed']) . " Feed</title>\n";
$output .= "    <link>http://www.yourdomain.com</link>\n";
$output .= "    <description>Your feed description</description>\n";
$output .= "    <language>en-us</language>\n";
$output .= "    <generator>yourdomain.com</generator>\n";
$output .= $items;
$output .= "</channel>\n</rss>";

// send the results to the browser or feed reader
echo $output;
?>

3. Upload both files to your root directory. Create a link to http://www.yourdomain.com/rss.php wherever you want it. That is what you'll want to add to feed readers, My Yahoo, Bloglines, etc.

That should do it!

Jeff

#9 Bradnjxn

Bradnjxn

    Advanced Member

  • Members
  • PipPipPip
  • 90 posts

Posted 13 September 2005 - 08:43 PM

jeffhope,

you're awesome! I'll give it a try. I'm very excited!

#10 sluggo

sluggo

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 28 October 2005 - 04:21 AM

Hello Jeff,

I'm hoping you can help me out here. I tried adding your code so that I would have a rss feed for my blog. I tried adding the feed url to my.yahoo. The first time I did it, yahoo seemed to find the blog titles. Upon refreshing, my.yahoo isn't picking up the feed anymore. I suppose I don't have the rss.php file edited correctly.

When I created the blog, two tables were created: BLOG_CATEGORY AND BLOG_CONTENT
Inside BLOG_CONTENT there are some rows including BLOG_DATE, BLOG_DATA and BLOG_TITLE

I edited your text as follows:

<?php

// connect to the database
@include('xconnect.php');

// we only want events for today & after so define today's date
$today = date('Y-m-d');

// define sql query, limit to 10 events dated today or after, 
// and sorted by nearest event date first
$result = mysql_query("SELECT * FROM BLOG_CONTENT WHERE BLOG_DATE >= '" . $today . "' ORDER BY BLOG_DATE limit 10");

// loop through sql query results
while ($row = mysql_fetch_array($result)) {

// define data for current row, we want to send visitors to the Blog page
// when they click on one of our feed items
  $title = $row[BLOG_DATE] . ' - ' . $row[BLOG_TITLE];
  $url = 'http://www.dryfly.ca/index.php?pr=blogger';
// show first 250 characters of event description in this item
  $desc = strip_tags(substr($row[BLOG_DATA],0,250));

// remove some characters as they cause problems in RSS feeds
  $desc = str_replace("&",'',$desc);

// create the XML structure for this row, adding on to previous rows
// and using the fields defined above
  $items     .= "     <item>\n";
  $items     .= "       <title>$title</title>\n";
  $items     .= "       <link>$url</link>\n";
  $items     .= "       <description>$desc</description>\n";
  $items     .= "     </item>\n";

}

// must output xml header
header("Content-type: text/xml; charset=iso-8859-1");

// create heading & channel data for feed
$output .= "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
$output .= "<!-- generator=\"dryfly.ca\" -->\n";
$output .= "<!DOCTYPE rss >\n";
$output .= "<rss version=\"0.92\">\n";
$output .= "  <channel>\n";
$output .= "    <title>dryfly" . ucwords($_GET['feed']) . " Feed</title>\n";
$output .= "    <link>http://www.dryfly.ca</link>\n";
$output .= "    <description>dryfly news</description>\n";
$output .= "    <language>en-us</language>\n";
$output .= "    <generator>dryfly.ca</generator>\n";
$output .= $items;
$output .= "</channel>\n</rss>";

// send the results to the browser or feed reader
echo $output;
?>
I'm assuming that I created the xconnect.php file correctly.
Does anything jump out at you that I did something wrong?

Thanks
Doug

#11 jeffhope

jeffhope

    Member

  • Members
  • PipPip
  • 15 posts

Posted 28 October 2005 - 04:30 AM

Hi Doug,

In your code, there may be other problems, but the first thing I see is that you need to enclose your MySQL result fields with single quotes:

not this:

$title = $row[BLOG_DATE] . ' - ' . $row[BLOG_TITLE];

but this:

$title = $row['BLOG_DATE'] . ' - ' . $row['BLOG_TITLE'];

This will apply to all references to $row['fieldname']

You might try changing those first, then post back here if it still doesn't work.

Jeff

#12 sluggo

sluggo

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 28 October 2005 - 05:23 AM

very cool, thanks for your initial work on this and your help tonight.

regards,
Doug

#13 genewell

genewell

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 10 May 2006 - 02:32 AM

While I'm still confused about outbound RSS feeds and how to create them (which led me to this entry), I have to commend you for this site. It has very rich content and the websiteis clean and navigable. Thanks for sharing it!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users