Recent Topics

1 Jan 21, 2005 06:14    

A stripped down uni-purpose version of my magpierss hack. All it does is read feeds from Gallery and put thumbs in your sidebar. Here's the short version. Step one: get [url=http://magpierss.sourceforge.net/]magpierss[/url] and put the extlib folder and 4 rss_ files in your skins/skinname folder. Step two: put something like

<?php require( dirname(__FILE__).'/rss_fetch.inc' ); ?>
<div class="bSideItem">
<h3>Magpie Does Gallery</h3>
<?php 
$url = "http://blahblahblah.tld/gallery/rss.php";
$rss = fetch_rss($url);
require( dirname(__FILE__).'/_galleryreader.php' );
?>
</div>


in your sidebar in _main.php. Step C is to put

<?php 
/**
 * This file uses magpierss (magpierss.sourceforge.net) to read feeds from
 * gallery (gallery.menalto.com) and display a thumbnail in the sidebar.
 *
 * This requires magpieRSS which is not part of the b2evolution distribution
 * magpieRSS is released under the GPL License and the author holds copyright
 * This application makes absolutely no modifications to the magpieRSS files!
 * Download it, unzip it, and upload the files to your /skins/skinname folder
 *
 * magpieRSS - {@link http://magpierss.sourceforge.net/}
 * Released under the GNU General Public License.
 * @copyright (c)2002 kellan @ protest.net. All rights reserved.
 * Please read the disclaimer at the top of the /extlib/Snoopy.class.inc file.
 *
 * Gallery - {@link http://gallery.menalto.com/}
 * Released under the GNU General Public License.
 * @copyright (c)2000-2004 Bharat Mediratta
 * 
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2004 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * @package evoskins
 * @subpackage your_skin_name
 */

if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );

# set this to false if you don't want to show the name of the gallery
# if false then 'gallery_start', 'gallery_end' and 'gallery_linked' don't get used
$show_site_name = true;
# this is for the name of the gallery
$gallery_start = '<h4>';
$gallery_end = '</h4>';
# set this to false if you don't want the gallery title linked to it's url
$gallery_linked = true;

# this is for the before and after all the thumbnails
$thumb_block_start = '';
$thumb_block_end = '';

# this is for the before and after each thumbnail
$thumb_start = '<p>';
$thumb_end = '</p>';

# set this to false if you don't want thumnails linked to thier url
$thumb_linked = true;

# this is what comes after the src and title and alt in the img tag
$thumb_tag_end = 'class="middle"';

# this is how many items to show if it is not set in _main.php
if(!isset($show_me)) $show_me = 10;

// BEYOND HERE BE DRAGONS!

if( $rss ) {

	if( $show_site_name ) { // do this if the site name gets displayed
		$site_title = $rss->channel['title'];
		$site_url = $rss->channel['link'];
		$site_desc = $rss->channel['description'];

		$gallery_string = "";
		$gallery_string .= $gallery_start;
		if( $gallery_linked ) {
			$gallery_string .= "<a href=\"".$site_url."\" title=\"".$site_desc."\">".$site_title."</a>";
			} else {
			$gallery_string .= $site_title;
			}
		$gallery_string .= $gallery_end."\n";
		echo $gallery_string;
		}

	echo $thumb_block_start."\n";
	$ii = 1;

	foreach ($rss->items as $item ) { // now start cycling through items
		if( $ii <= $show_me ) { // do it again if we have not reached the limit

			$thumb_title = $item[title];
			if( $thumb_title == '' ) { // if the item is untitled then make one up
				$thumb_title = substr(strip_tags($thumb_desc), 0, 20).'...';
				}

			$thumb_url = $item[link];
			if ( $thumb_url == '' ) { // if the item has no link then use the site link
				$thumb_url = $rss->channel['link'];
				}

			$thumb_image = $item[photo][imgsrc];
			$thumb_image = '<img src="'.$thumb_image.'" title="'.$thumb_title.'" alt="'.$thumb_title.'" '.$thumb_tag_end.' />';

			$thumb_image_string = "";
			$thumb_image_string .= $thumb_start;
			if( $thumb_linked ) { // do this if the item gets linked
				$thumb_image_string .= "<a href=\"".$thumb_url."\" title=\"link to ".$thumb_title."\">".$thumb_image."</a>";
				} else { // do this if the item title does not get linked
				$thumb_image_string .= $thumb_image;
				}
			$thumb_image_string .= $thumb_end;

			echo $thumb_image_string;
			}
		$ii++;
		}

	echo $thumb_block_end."\n";

	} else {
	echo "<p>Houston we have a problem</p>";
	}

?>

in your skins/skinname folder as _galleryreader.php.

Decorate as you see fit. I think it's got enough stuffers to let you do your thing your way. By the way I only tested this on one gallery installation. It's possible that they have more than one feed but I don't know. The file I pulled from was "rss.php" if that helps.

Finally, if you want, you can throw some traffic my way by reading the same thing on [url=http://wonderwinds.com/hackblog.php/2005/01/20/gallery_feed_reader_for_b2evolution]my blog[/url].

2 Feb 03, 2005 20:48

it works and i really like it. but how can i control where it pulls the thumbs from? i've looked in the rss.php file and others but i'm not that code savvy.

i'd like to just post thumbs from the newest album i put into gallery.

3 Feb 03, 2005 21:19

You'd have to either limit it to pulling 1 image (which seems to be the newest but I could be wrong), or talk to gallery about how to control that aspect of their rss feed. I don't know if you can get (for example) more than one thumb from each gallery, or if you can create a unique feed for each gallery and then subscribe to only the newest. A quick look at their code tells me you can't, so that leaves you with either hacking thier code or only pulling one thumb with this hack.

4 Feb 07, 2005 17:22

The Gallery supplied rss feed script just shows the thumbnails for the Gallery highlight but there are a couple of Gallery-user versions of the RSS feed to do different things. You can find these here:

[url=http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=22361]RSS Option 1[/url]

[url=http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=18415]RSS Option 2[/url]

Also, just if anyone's interested, I added a random picture to my blog page using:

<div class="bSideItem">
<h3>Random Photo</h3>
<?php
@include 'http://yourdomain.tld/gallery/block-random.php' );
?>
</div>

John

5 Feb 16, 2005 16:27

edB,
I was trying to get my site to validate with xhtml amd css and discovered a couple of little issues with this script.

First up, I'm using both _galleryreader and _magpierss on the same page and the variables $block_start and $block_end conflict. I renamed the ones in _galleryreader to $image_block_start and $image_block_end.

Second is a little typo on this line:

$thumb_image_string .= $$thumb_end;

it should read:

$thumb_image_string .= $thumb_end;

Thanks
John

6 Feb 16, 2005 16:36

Cool. Corrected in code up above. Called them $thumb_block_.... to go with the thumb theme.


Form is loading...