PDA

View Full Version : Implementing Mint v2.2 & Bird Feeder (A how to guide)


Dkozikowski
02-08-2007, 03:33 PM
How to implement Mint's Bird Feeder Pepper with pixelpost's RSS 2.0 Feed.
A How to guide for pixelpost 1.5

NOTE! This following procedure requires "hacking" the index.php file. Currently, there is no way for an addon to perform this function that i know of!

Please make a backup of your index.php file and rename it to index-bak.php and store it in a safe place!

Step 01

Download the latest release of Bird Feeder from http://haveamint.com/peppermill/
Extract the Bird Feeder pepper and continue following the steps bellow.


Step 02

Upload the /birdfeeder/ directory and its contents to /mint/pepper/shauninman/. If the directory /shauninman/ doesn't exist, create it.


Step 03

Login to your Mint installation and in the Preferences click "Install" under Pepper.
Click the Bird Feeder Pepper "Install" button. Click "Okay".
While you're here, if you also have the User Agent 007 Pepper installed, remember to enable reader detection. You can do this by visiting the User Agent 007 preferences pane.

NOTE: If you are using the .htaccess method to attach Mint to your pages you are on your own! Additional steps are required and although the bellow steps will apply to you, I'm not going to support this method in this thread! Refer to the readme file included with Bird Feeder.


OK, now you can continue with the installation steps outlined below.


Step 04

Unzip and upload the /feeder/ directory to the root of your site.
Visit http://yourdomain.com/feeder/. If you see an error, please visit the
Mint Forum for a solution.


Step 05

Open index.php
Find the following, (on lines 764, 765, 766 & 767 of an un-hacked index.php file)

<?php // Do not add this line if you are copying and pasting!

if(isset($_GET['x'])&&$_GET['x'] == "rss")

{
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>

Add replace with this

<?php // Do not add this line if you are copying and pasting!

if(isset($_GET['x'])&&$_GET['x'] == "rss")

{
define('BIRDFEED', 'Article (RSS)'); // Mint Bird Feeder Hack
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>

NOTE: You may change 'Article (RSS)' to 'Whatever You Want'
This will give your feed a name while viewing your Mint Stats.


Find the following, (on line 790 of an un-hacked index.php file)

$query = mysql_query("SELECT id,datetime,headline,body,image FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') ORDER BY datetime desc limit 10");

Copy and paste the bellow code directly bellow the line of code mentioned above.

include($_SERVER['DOCUMENT_ROOT'].'/feeder/index.php'); // Mint Bird Feeder Hack

Find the following, (on line 808 of an un-hacked index.php file)

<link>".$cfgrow['siteurl']."?showimage=$id</link>

and replace with this:

<link>".$BirdFeeder->seed($headline, "{$cfgrow['siteurl']}?showimage={$id}", true)."</link> <!-- Mint Bird Feeder Hack -->



Step 06

You're done!
Save index.php and visit http://yourdomain.com/?x=rss and mouse over a link while looking in the status bar to make sure Bird Feeder is working. You will be able to tell due to the nastiness of the Bird Feeder Url.


You may also visit my RSS feed for an example (uses post slug urls described bellow).
Mouse over one of the links to see what the actual Bird Feeder link looks like.
Click on the link to see how the Bird Feeder uses that link to record (invisible to users) and redirect you to the proper image.

http://dwilkinsjr.com/rss.xml
(don't mind the rss.xml part. I use mod-rewrite to change the url. index.php?x=rss also works)

Dkozikowski
02-08-2007, 03:39 PM
Using the post slug addon?

If you have previously hacked the RSS function of index.php to allow the use of the post slug addon, you can substitute the following code

<link>".$BirdFeeder->seed($headline, "{$cfgrow['siteurl']}?showimage={$id}", true)."</link> <!-- Mint Bird Feeder Hack -->

with,

<link>".$BirdFeeder->seed($headline, "{$cfgrow['siteurl']}{$slug}", true)."</link> <!-- Mint Bird Feeder Hack -->

Paul Wood
03-09-2007, 03:40 PM
I'm getting this error:

Parse error: parse error, unexpected T_DNUMBER in /home/pnjwood/fotoblog/index.php on line 768

My line 768 reads:

$output = "<?xml version="1.0\" encoding=\"UTF-8\"?>

Paul Wood
03-09-2007, 04:22 PM
I got my page to load by changing
$output = "<?xml version="1.0\" encoding=\"UTF-8\"?>
to
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
but now my rss page is blank.

Any ideas?

Dkozikowski
03-09-2007, 04:32 PM
You're right. That was a typo on my part.

I'm not sure why you are receiving a blank RSS page.

Here is my RSS code for you to compare


<?php // Do not add this line if you are copying and pasting!
if(isset($_GET['x'])&&$_GET['x'] == "rss")

{
define('BIRDFEED', 'Article (RSS)'); // Mint Bird Feeder Hack
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<rss version=\"2.0\">
<channel>
<title>".$pixelpost_site_title."</title>
<link>".$cfgrow['siteurl']."</link>
<description>$pixelpost_site_title photoblog</description>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>pixelpost</generator>
";
$tzoner = $cfgrow['timezone'];
$tprefix = '+';
$tzoner = sprintf ("%01.2f", $tzoner);
if (substr($tzoner,0,1)=='-')
{
$tzoner = (substr($tzoner,1));
$tprefix = '-';
}

if ($tzoner < 10) $tzoner = "0".$tzoner;

$hh = substr($tzoner,0,2);
$mm = substr($tzoner,-2);
$tzoner = $tprefix.$hh.$mm;
$query = mysql_query("SELECT id,datetime,headline,body,image FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') ORDER BY datetime desc limit 10");

include($_SERVER['DOCUMENT_ROOT'].'/feeder/index.php'); // Mint Bird Feeder Hack

while(list($id,$datetime,$headline,$body,$image) = mysql_fetch_row($query))
{
$headline = pullout($headline);
$headline = htmlspecialchars($headline,ENT_QUOTES);
$image = $cfgrow['siteurl']."thumbnails/thumb_$image";
$datetime = strtotime($datetime);
$datetime =date("D, d M Y H:i",$datetime);
$datetime .= ' ' .$tzoner;
$body = pullout($body);
$body = stripslashes($body);
$body = strip_tags( $body );
$body = htmlspecialchars($body,ENT_QUOTES);
$body = ereg_replace("\n","\n&lt;br /&gt;",$body);
$output .= "
<item>
<title>$headline</title>
<link>".$BirdFeeder->seed($headline, "{$cfgrow['siteurl']}?showimage={$id}", true)."</link> <!-- Mint Bird Feeder Hack -->
<description>
&lt;img src=&quot;$image&quot;&gt;
&lt;br /&gt;$body
</description>
<pubDate>$datetime</pubDate>
<guid>".$cfgrow['siteurl']."index.php?showimage=$id</guid>
</item>
";
}
$output .= "
</channel>
</rss>";
header("Content-type:application/xml");
echo $output;
exit;
}
?> // Do not add this line if you are copying and pasting!

Paul Wood
03-09-2007, 04:36 PM
I figured out why. Haven't figured out how to fix it, though.

I'm running a subdomain, and there are actually 2 ways to reach my site:
fotoblog.pnjwood.com and pnjwood.com/fotoblog. The first can't find my mint directory, since the server document root is different.

I may try hard coding paths in and see what happens.

Dkozikowski
03-09-2007, 04:39 PM
Ah, ok. Well you can try,


include('./feeder/index.php'); // Mint Bird Feeder Hack

Tiestoo
05-17-2008, 01:23 PM
Maybe a little bit lazy, but since I'm not a real hero on this kind of hacking and coding I'll give it a try: will this modification still work with PP 1.7 in combination with the newest Mint release?

Dkozikowski
05-17-2008, 03:41 PM
Should. Same basic concept. . .

Tiestoo
05-19-2008, 08:13 AM
I can't find the lines mentioned in step 5. I think they were re-written in a update. dwilkinsjr, is it a possibility to update your step 5 so it works with PP 1.7? I tried to replace some lines, but my feed didn't work anymore! Would really appreciate that!

Dkozikowski
06-11-2008, 10:14 PM
I can't find the lines mentioned in step 5. I think they were re-written in a update. dwilkinsjr, is it a possibility to update your step 5 so it works with PP 1.7? I tried to replace some lines, but my feed didn't work anymore! Would really appreciate that!

Attached is a modified functions_feeds.php file.

Unzip and replace your old functions_feeds.php file located in the includes/ folder with my modified functions_feeds.php file.
Make sure your Mint feeder/ folder is located in the root directory of your site. If it is not then you will have to modify my functions_feeds.php file and correct all path occurrences:
include($_SERVER['DOCUMENT_ROOT'].'/feeder/index.php'); // Mint Bird Feeder Hack


Compatible with Pixelpost 1.7.1 only

Tiestoo
06-12-2008, 08:00 AM
Thanks a lot, works like a charm! :D