vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Creating my own page w/ RSS. Need help (https://vborg.vbsupport.ru/showthread.php?t=72782)

MikeeX 12-11-2004 11:19 PM

Creating my own page w/ RSS. Need help
 
Hello everyone! Hopefully I'm in the right forum :)

What I'm trying to do is setup my own vb powered page with RSS feeds on it. Now I created my php file and the template. You can view it here:

http://forums.winforums.org/technews.php

I'm using Magpie to parse the RSS. Now I have a file called technewsdata.php which is called from a varible in my phpinclude_start template.

technewsdata.php
PHP Code:

<?

require_once 'rss_fetch.inc';

$url = 'http://rssnewsapps.ziffdavis.com/tech.xml';
$rss = fetch_rss($url);

echo "Site: ", $rss->channel['title'], "<br>\n";
foreach ($rss->items as $item ) {
    $title = $item[title];
    $url   = $item[link];
    echo "<a href=$url>$title</a></li><br>\n";
}

?>

As you can see, this works perfect (check out link posted above). Now, I want to add about 5-10 more RSS feeds like this to the same page. Now I don't know PHP at all, so I'm not sure how to accomplish this. How can I use the ONE technewsdata.php file for all my RSS feeds? Is it called an array? That's where I'm hoping you guys could help me. So I don't have to create say, technewsdata_slashdot.php, with the same parse information above. I want to utilize one php file.

I hope this makes sense, and if not let me know what else you need from me.

Any help or information on this would be greatly appreciated!

AN-net 12-11-2004 11:23 PM

there some nice php rss tutorials out there, you can look in the external.php file for ideas and also on google;)

MikeeX 12-11-2004 11:25 PM

external.php would be used if I wanted to use to create my own RSS correct? I'm asking pretty much how can I use php code all in one file, w/ multiple RSS feeds added to it.

Or...am I missing something?

MikeeX 03-08-2005 02:52 PM

Thought I would post what I did. Just in case others are interested

PHP Code:

<?

require_once 'rss_fetch.inc';

// Section 1

echo '<table cellspacing="7" cellpadding="7" width="100%">';

// RSS 1

$url1 = 'URL TO RSS';
$num_items1 = 7;
$rss1 = fetch_rss($url1);

if ( $rss1 ) {

}
else {
   echo "Error reading news feed  " .
        "Check back later" .
        "<br>Error Message: " . magpie_error();
}

echo '<tr>';
echo '<td valign="top">';
echo "&nbsp;&nbsp;Source: <b>", $rss1->channel['title'], "</b><p>\n";
$items1 = array_slice($rss1->items, 0, $num_items1);
foreach ( $items1 as $item1 ) {
    $title1 = substr($item1[title], 0, 50);
        //$title1 = $item1[title];
        $url1   = $item1[link];
    echo "? <a href=$url1>$title1</a></li><br>\n";
}
echo '</td>';
echo '<td valign="top">';

// RSS 2

$url2 = 'URL TO RSS';
$num_items2 = 7;
$rss2 = fetch_rss($url2);

if ( $rss2 ) {

}
else {
   echo "Error reading news feed  " .
        "Check back later" .
        "<br>Error Message: " . magpie_error();
}


echo "&nbsp;&nbsp;Source: <b>", $rss2->channel['title'], "</b><p>\n";
$items2 = array_slice($rss2->items, 0, $num_items2);
foreach ( $items2 as $item2 ) {
    $title2 = substr($item2[title], 0, 50);
        //$title2 = $item2[title];
    $url2   = $item2[link];
    echo "? <a href=$url2>$title2</a></li><br>\n";
}
echo '</td>';
echo '</tr>';
echo '</table>';

// Section 2

echo '<table cellspacing="7" cellpadding="7" width="100%">';

// RSS 3

$url3 = ' URL TO RSS';
$num_items3 = 7;
$rss3 = fetch_rss($url3);

if ( $rss3 ) {

}
else {
   echo "Error reading news feed  " .
        "Check back later" .
        "<br>Error Message: " . magpie_error();
}

echo '<tr>';
echo '<td valign="top">';
echo "&nbsp;&nbsp;Source: <b>", $rss3->channel['title'], "</b><p>\n";
$items3 = array_slice($rss3->items, 0, $num_items3);
foreach ( $items3 as $item3 ) {
    $title3 = substr($item3[title], 0, 50);
        //$title3 = $item3[title];
    $url3   = $item3[link];
    echo "? <a href=$url3>$title3</a></li><br>\n";
}
echo '</td>';
echo '<td valign="top">';

// RSS 4

$url4 = 'URL TO RSS';
$num_items4 = 7;
$rss4 = fetch_rss($url4);

if ( $rss4 ) {

}
else {
   echo "Error reading news feed  " .
        "Check back later" .
        "<br>Error Message: " . magpie_error();
}


echo "&nbsp;&nbsp;Source: <b>", $rss4->channel['title'], "</b><p>\n";
$items4 = array_slice($rss4->items, 0, $num_items4);
foreach ( $items4 as $item4 ) {
    $title4 = substr($item4[title], 0, 50);
        //$title4 = $item4[title];
    $url4   = $item4[link];
    echo "? <a href=$url4>$title4</a></li><br>\n";
}
echo '</td>';
echo '</tr>';
echo '</table>';

?>



All times are GMT. The time now is 01: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.01438 seconds
  • Memory Usage 1,740KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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