Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons

Reply
 
Thread Tools
Latest blog in postbit - magpierss Details »»
Latest blog in postbit - magpierss
Version: 1.00, by vauge vauge is offline
Developer Last Online: Dec 2013 Show Printable Version Email this Page

Version: 3.5.0 RC2 Rating:
Released: 08-01-2005 Last Update: Never Installs: 9
Uses Plugins Template Edits
 
No support by the author.

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

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-12-2005, 10:08 AM
WonderWorm WonderWorm is offline
 
Join Date: Jun 2002
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 08-13-2005, 12:57 PM
vauge vauge is offline
 
Join Date: Oct 2004
Posts: 114
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome - thanks for the catch.

I didn't limit it, in case I wanted to pull the RSS for other pages.
Reply With Quote
  #4  
Old 08-16-2005, 11:11 PM
GilbertZ GilbertZ is offline
 
Join Date: Nov 2004
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #5  
Old 08-16-2005, 11:19 PM
vauge vauge is offline
 
Join Date: Oct 2004
Posts: 114
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 08-16-2005, 11:26 PM
GilbertZ GilbertZ is offline
 
Join Date: Nov 2004
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 08-17-2005, 02:45 AM
GilbertZ GilbertZ is offline
 
Join Date: Nov 2004
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 08-17-2005, 03:26 AM
GilbertZ GilbertZ is offline
 
Join Date: Nov 2004
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 08-17-2005, 03:57 AM
GilbertZ GilbertZ is offline
 
Join Date: Nov 2004
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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); 
Reply With Quote
  #10  
Old 08-21-2005, 12:07 PM
vauge vauge is offline
 
Join Date: Oct 2004
Posts: 114
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:55 AM.


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.04515 seconds
  • Memory Usage 2,323KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete