vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Latest blog in postbit - magpierss (https://vborg.vbsupport.ru/showthread.php?t=93457)

vauge 08-01-2005 10:00 PM

Latest blog in postbit - magpierss
 
For this hack, we are using magpierss - simple and GPL.
================================================== =========
MagpieRSS provides an XML-based (expat) RSS parser in PHP.

MagpieRSS is compatible with RSS 0.9 through RSS 1.0. Also parses RSS 1.0's modules, RSS 2.0, and Atom. (with a few exceptions)

http://magpierss.sourceforge.net/
================================================== =========
Idea came from DigitalPoint. I have actually been using this for several months on my forum.
But with the new plugin system, it's even easier to share.

Install instructions:

Step 1)
Magpierss

Download & Install: http://magpierss.sourceforge.net/

Create a "cache" directory or make sure path is ok in: MAGPIEDIR/rss_cache.inc


Step 2)
Create a new profile field for the Blog - Note the field#
The example below is field 7.


Step 3)
Edit magpierss.xml
1. include your full path to magpierss/rss_fetch.inc
2. Change field 7 to applicable field.

PHP Code:

<?xml version="1.0" encoding="ISO-8859-1"?>



<plugins>
    <plugin active="1" product="vbulletin">
        <title>Magpierss_include</title>
        <hookname>global_start</hookname>
        <phpcode><![CDATA[require_once '/Full Path to/magpierss/rss_fetch.inc';]]></phpcode>
    </plugin>
    <plugin active="1" product="vbulletin">
        <title>Magpierss_Get_Blog</title>
        <hookname>postbit_display_start</hookname>
        <phpcode><![CDATA[if ($post['field7']){
$rss = fetch_rss( $post['field7'] );
foreach ($rss->items as $item) {
        $blogLink = $item[0]['link'];
        $blogTitle = $item[0]['title'];
    }
}]]></phpcode>
    </plugin>
</plugins>

Step 4)
Import magpierss.xml


Step 5)
In your postbit template add the following (note field #!):

PHP Code:

            <if condition="$post['field7']">
            <
div class="smallfont">Recent Blog: <a href="$blogLinktarget="_blank">$blogTitle</a></div>
                        </if> 

===============================================
Attached files: 2
Template Edits: 1
Simplicity: Easy
Time: < 30 mins, 5 mins for advanced users

Attached is a screen from another nevetS's Blog Feed parser using Carp - it is just as relivant.
https://vborg.vbsupport.ru/showthread.php?t=91781

WonderWorm 08-12-2005 10:08 AM

Thanks clicked the Install .. going to check it out now. :)

- - - - -

Edit: I can't seem to get any output after installing this plugin.

I have installed MagpieRSS correctly. I created a directory called magpierss and uploaded the 4 main files along with the directory called extlib with the file Snoopy.class.inc in that directory. I then created a cache directory and set the proper permissions.

Next I created the profile field which was number 7 for me. Just a basic one line text field.

I then edited the xml file for the plugin and added my full path and double checked the field number which was already at 7. Then I used the plugin manager to upload the plugin xml file and it was added correctly.

Then I edited my postbit template with the if statement.

Now comes the problem .. the cache works fine and when I open the cache file in my editor it is reading the RSS feeds I am testing with just fine but on my post it never shows the post title or link.

Anyone else have this issue or am I missing something?

Example of where I have it .. maybe the placement? but the hook seems to be for the whole postbit so not sure there.

http://forums.emufanatics.com/showth...=5751#post5751

- - - - - - -

Edit2: I did a standalone test just using MagpieRSS .. and it works so at least I know it's not the server. .. http://forums.emufanatics.com/rsstest.php

- - - - - - -

Edit3: Sorry for so many edits. After checking out some of the included documentation for MagpieRSS I noticed in the recipes file they showed how to limit the number of posts to show .. so I went ahead and stuck this into the plugin and now it works perfectly for me. Here is the code I used.

Code:

if ($post['field7']){
$num_items = 1;
$rss = fetch_rss($post['field7']);
$items = array_slice($rss->items, 0, $num_items);
foreach ( $items as $item ) {
$blogTitle = $item['title'];
$blogLink = $item['link'];
               
        }
}

Many thanks for this great plugin. :)

vauge 08-13-2005 12:57 PM

Awesome - thanks for the catch.

I didn't limit it, in case I wanted to pull the RSS for other pages.

GilbertZ 08-16-2005 11:11 PM

Since there's a cache I'm assuming that this doesn't mean every time showthread.php is called that it's a hit on all the feeds of that page, does it?

vauge 08-16-2005 11:19 PM

Quote:

Originally Posted by GilbertZ
Since there's a cache I'm assuming that this doesn't mean every time showthread.php is called that it's a hit on all the feeds of that page, does it?

Only if someone has a blog link in the thread and only the amount of time between caches.
I have mine set on an hour. If 3 folks in the thread have blogs it could potentially be 3 hits getting feeds.

GilbertZ 08-16-2005 11:26 PM

Meaning if there are 3 blogs then it can be up to 3 hits per hour?

Although this hack is working for me, I looked in my cache directory and it's empty. I went into a thread where I know there are a couple blog links and same story.

Do you see data in your cache?

Any suggestions to debug this? I'd like to test it in a way to see what error messages would come up when trying to create the cache.

Just as a test I made the most lenient permissions on the cache directory yet nothing comes up.

GilbertZ 08-17-2005 02:45 AM

I fixed it. If you don't see a file in your cache directory, that means cache isn't working for you. To debug this, open your rss_fetch.inc file.

Explicitly define the full path to your cache directory.
PHP Code:

    if ( !defined('MAGPIE_CACHE_DIR') ) {
        
//define('MAGPIE_CACHE_DIR', './cache');
        
define('MAGPIE_CACHE_DIR''/path/to/magpie/cache');
    } 

Turn on DEBUG mode.
PHP Code:

    if ( !defined('MAGPIE_DEBUG') ) {
        
define('MAGPIE_DEBUG'1);
    } 

Make sure permissions are good for the cache directory. Then create a simple test.php file containing this, but replace your data where necessary:
PHP Code:

<html><head></head><body>

<?
$url="http://www.url.com/to/your/external.php?type=RSS";

require('/path/to/magpie/rss_fetch.inc');
$rss = fetch_rss($url);
$num_items = 25;
$count=1;
$items = array_slice($rss->items, 0, $num_items);
foreach ( $items as $item ) {
$blogTitle = $item['title'];
$blogLink = $item['link'];
echo "$count <a href=$blogLink target=_blank>$blogTitle</a>";
echo "<br>";
$count++;
}
?>
</body>
</html>

Then call that page and if you see an error that should help you debug it. If you see the feed, you should be all set, but "ls cache" and look for files to be sure. ALSO, don't forget to turn DEBUG back off.


One more point on the hack the way it's currently put. I believe you are calling this in global.php unneccessarily. This adds an include on every single page of vbulletin. Instead of two hooks, just remove the hook to the global and stick that line
require_once '/path/to/magpie/rss_fetch.inc';
in the postbit hook and it'll work fine and reduce load.

GilbertZ 08-17-2005 03:26 AM

Sorry for the serial posts, but there is a huge problem with this hack. If a user puts in a bogus entry, any thread with that user will get a big error message passed from magpie. There needs to be a way to suppress errors.

It would also be a good idea when creating the custom profile field to get a good REGEXP to validate URLs. I'm looking for some code that will work. If you have it, please post to this thread:

http://www.vbulletin.com/forum/showt...486#post943486

GilbertZ 08-17-2005 03:57 AM

Although I'm still missing a good regexp for url validation that works w/ vb, I did fix everything else. Here's how. Modify your plugin to look like this:

PHP Code:

//Set error reporting to 0 so if fetching the rss fails you won't 
//mess up showthread.php. We'll reset it after we're done here.
error_reporting(0);

require_once 
'/path/to/magpie/rss_fetch.inc';
//fieldX needs to be replaced with the number of your custom profile field
if ($post['fieldX']){
$num_items 1;

//fieldX needs to be replaced with the number of your custom profile field
$rss fetch_rss($post['fieldX']);

//ONLY process the rss feed if you actually got one
if($rss)
{

$items array_slice($rss->items0$num_items);
foreach ( 
$items as $item ) {
$blogTitle $item['title'];
$blogLink $item['link'];
}
}
}
//reset error reporting
error_reporting(E_ALL & ~E_NOTICE); 


vauge 08-21-2005 12:07 PM

Quote:

Originally Posted by GilbertZ
Although I'm still missing a good regexp for url validation that works w/ vb, I did fix everything else. Here's how. Modify your plugin to look like this:

PHP Code:

if ($post['field7']){
    if (
eregi("(xml|rss)"$post['field7'])){
        
$rss fetch_rss$post['field7'] );
        
$items array_slice($rss->items01);
        
$blogLink $items[0]['link'];
        
$blogTitle $items[0]['title'];
   }


Since I am pulling whole thing, might not be applicable to your changes.
I tried checking for XML or RSS in the URL before it runs. So far, it appears to be working for me.

GilbertZ 08-21-2005 06:09 PM

What do you mean "pulling the whole thing"?

vauge 08-21-2005 09:46 PM

My code is pulling all the items into an array, then doing an array_slice.
(in case I ever want to display more than one)

Your code is only pulling & cacheing 1 item.

GilbertZ 08-22-2005 10:10 AM

OK, that's what I thought but I wanted to double check.

My code wasn't really related to that. It's just to do some error checking. For example let's say a user puts this in their blog field:

"htpt:\\theirdomain.com/ url.html"

you will have a bad error. The error checking should save some nasty errors on top of the page of any thread that user posts in.

vauge 08-22-2005 10:37 AM

I wonder if error checking would be better in the CP instead of runtime?

GilbertZ 08-22-2005 03:11 PM

You definitely want to error check at runtime (as well as CP) because a url that's good today can be bad tomorrow.

WhatChaMissin 12-08-2005 11:20 AM

its there anyway to combine this hack with vBJournal?

lanc3lot 12-08-2005 12:15 PM

Yes, me to have the same question as the above :)

Qwest 12-15-2005 12:09 AM

The hack itself doesn't even work without hacking it yourself.

The author hasn't posted or updated since August.

Suggest someone create a better one.

Shoemoney 01-15-2006 04:04 AM

Before I found this thread I have already done my new board with up to 3 blogs in the postbit. I will post the code if enough people would like to have it

demo - http://www.pimpmyblog.com/forum/showthread.php?t=43

WhatChaMissin 01-15-2006 02:44 PM

Quote:

Originally Posted by Shoemoney
Before I found this thread I have already done my new board with up to 3 blogs in the postbit. I will post the code if enough people would like to have it

demo - http://www.pimpmyblog.com/forum/showthread.php?t=43

I would be interested but really only need the latest blog to show up for vBJournal.

Thanks

Shoemoney 01-15-2006 07:21 PM

I will look into it and probably make my own release sometime next week.

WhatChaMissin 01-16-2006 03:36 AM

Thanks, I'll be on the lookout

lexx27 07-18-2006 02:31 AM

any news...

ablaye 04-08-2007 08:38 PM

I installed the mod on my forum at http://www.WebmasterGround.com and after a few code changes, it worked as a charm.
The download files do not work if you do not modify them.

wtricks 07-22-2007 03:32 PM

What did you do?

I tried all the code changes and I am just losing my minds. Carp RSS is not working either, this one is not working .. coult it be that I am that stupid :(

I tested it: http://www.wtricks.com/forums/magpierss/test.php

It does pull my titles it seems.

But I cannot make this show in my postbit for the life of me. What am I doing wrong?

pmkb 08-27-2007 03:06 PM

I posted an updated solution here:

https://vborg.vbsupport.ru/showthread.php?t=156372

revolver 09-28-2007 04:05 PM

Quote:

Originally Posted by wtricks (Post 1298310)
What did you do?

I tried all the code changes and I am just losing my minds. Carp RSS is not working either, this one is not working .. coult it be that I am that stupid :(

I tested it: http://www.wtricks.com/forums/magpierss/test.php

It does pull my titles it seems.

But I cannot make this show in my postbit for the life of me. What am I doing wrong?

This version works. It's a pain in the bum to install and get working, and you have to make Wonderworms changes for it to display the actual feed.

My suggestion is this. First off make sure that you are using the FULL PATH to the Magpie directory on your server.

If you are unsure about the fullpath, then create a php file that includes the following:

Code:

<?php echo realpath(dirname(__FILE__)); ?>
then upload that file to the same location as your Magpie directory and navigate to it using your browser. Your full path will then be displayed.

Ensure that you replace this part in the magpierss XML file:
Code:

/Full+Path+to/magpierss/rss_fetch.inc
with your Full path. It will be something like /home/username/public_html/magpie/rss_fetch.inc

Where username is the username on your host, and magpie is what you called the magpie directory on your server that you uploaded the files to.

I hope that dumbs it down a shade. If that's not your problem and it was something else let me know because it took me a few goes to get it to work and I probably had the same errors along the way.


All times are GMT. The time now is 08:00 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01323 seconds
  • Memory Usage 1,833KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (7)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (27)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete