0

I Just need some correct results from 6 rss feed I am fetching 6 feeds and maked a news ticker bar at http://thehoopdoctors.com/online2/newfeed/

I am getting results from 6 rss feeds like First getting all posts from http://thehoopdoctors.com/online2/newfeed/", Then All "http://thepigskindoctors.com/newfeed/", Then All "http://thepuckdoctors.com/newfeed/", Then All "http://thecagedoctors.com/newfeed/", Then All "http://thedugoutdoctors.com/newfeed/", Then All "http://videogoneviral.com/newfeed/"

I just need get one by one.

I just need to get post from all urls one bye one like "http://thepigskindoctors.com/newfeed/", first post "http://thepuckdoctors.com/newfeed/", first post and so on.

my code is

<?php

$rsslist=array(
"http://thehoopdoctors.com/online2/newfeed/",
"http://thepigskindoctors.com/newfeed/",
"http://thepuckdoctors.com/newfeed/",
"http://thecagedoctors.com/newfeed/",
"http://thedugoutdoctors.com/newfeed/",
"http://videogoneviral.com/newfeed/"
);
$feed = fetch_feed($rsslist);
?>


<ul id="news-ticker" style="float: left;height: 15px !important; margin-left: 2px; margin-top: 10px; overflow: hidden; position: relative;width: 500px;">
<?php
foreach($feed->get_items() as $item) {?>
<li class="news"><a style="color:white !important;" href="<?php echo $item->get_permalink();?>"><?php echo $item->get_title();?></a></li>
<?php }?>
</ul>

1 Answer 1

0

What you're looking for is probably something along the lines of:

<ul id="news-ticker" style="float: left;height: 15px !important; margin-left: 2px; margin-top: 10px; overflow: hidden; position: relative;width: 500px;">
<?php
    $rsslist = array(
            "http://thehoopdoctors.com/online2/newfeed/",
            "http://thepigskindoctors.com/newfeed/",
            "http://thepuckdoctors.com/newfeed/",
            "http://thecagedoctors.com/newfeed/",
            "http://thedugoutdoctors.com/newfeed/",
            "http://videogoneviral.com/newfeed/"
        );
    foreach ( $rsslist as $rssurl ): /* For every URL in the feed list */
        $feed = fetch_feed($rrsurl);
        foreach( $feed->get_items() as $item ): /* For every item */ ?>
            <li class="news"><a style="color:white !important;" href="<?php echo $item->get_permalink();?>"><?php echo $item->get_title();?></a></li>
            <?php break; /* Do only once, we only need one item */ ?>
        <?php endforeach; ?>
    <?php endforeach; ?>
</ul>

Note how the code is fetching each URL separately instead of in multi-source mode and breaking out in the foreach $item loop as soon as an item is added. This should accomplish your task of getting one item from each feed in your ticker.

This code will do the same but grab each consecutive item from each feed:

<ul id="news-ticker" style="float: left;height: 15px !important; margin-left: 2px; margin-top: 10px; overflow: hidden; position: relative;width: 500px;">
<?php
    $rsslist = array(
            "http://thehoopdoctors.com/online2/newfeed/",
            "http://thepigskindoctors.com/newfeed/",
            "http://thepuckdoctors.com/newfeed/",
            "http://thecagedoctors.com/newfeed/",
            "http://thedugoutdoctors.com/newfeed/",
            "http://videogoneviral.com/newfeed/"
        );
    $feedlist = array();
    foreach ( $rsslist as $rssurl ) $feedlist []= fetch_feed( $rssurl ); /* store in feed array for later access */

    $current_item_cycle = 0;
    while ( sizeof($feedlist) ) { /* while feedlist is not empty */
        foreach ( $feedlist as $index => $feed ) { /* cycle through each feed */
            if (!$item = $feed->get_item($current_item_cycle++)) unset($feedlist[$index]); /* if feed has not more items unset */
            else /* echo it out */ { ?>
                <li class="news"><a style="color:white !important;" href="<?php echo $item->get_permalink();?>"><?php echo $item->get_title();?></a></li>
            <?php }
        }
    } ?>
</ul>
1
  • Thanks Man, I am very happy for his help, he always help me when i am worried about some thing. Commented Jan 12, 2012 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.