TinyPortal

Development => Support => Topic started by: makphisto on January 09, 2007, 10:44:58 PM

Title: RSS Feed Block - BUT, using PHP
Post by: makphisto on January 09, 2007, 10:44:58 PM
There is an RSS Feed that I want to display in a block. But the feed actually ends with rss.php (it's like http://www.website.com/rss/rssfeed/rss.php).  I've tried using the RSS feed block, but it just comes up as blank.  I tried a PHP block, but if I just put in the URL, I get a parse error - I'm not sure if I need something else or not.  Any suggestions?  Thanks.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: gerrymo on January 09, 2007, 11:17:10 PM
Try:

include('http://www.website.com/rss/rssfeed/rss.php');
Title: Re: RSS Feed Block - BUT, using PHP
Post by: makphisto on January 10, 2007, 12:53:35 PM
Hmm, that doesn't display it either.  There may be an issue with the RSS source.  I'll keep playing with it.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: Lesmond on January 10, 2007, 01:24:13 PM
can you post the feed and I will test it on my site for you :)
Title: Re: RSS Feed Block - BUT, using PHP
Post by: makphisto on January 10, 2007, 01:37:41 PM
Sure, the feed is:
http://www.gijoefirefight.com/faq/feed/topten/rss.php
And it comes from:
http://www.gijoefirefight.com/faq/

Thanks!
Title: Re: RSS Feed Block - BUT, using PHP
Post by: Lesmond on January 10, 2007, 01:45:45 PM
Just put it on my site in a front-page block and it works fine. have a look at my site its on the front page about half way down (link to site in my sig)
Title: Re: RSS Feed Block - BUT, using PHP
Post by: makphisto on January 10, 2007, 02:15:00 PM
Hmm, yep, looks great there.  Did you use PHP block with the include?  Or RSS somehow?  I tried both RSS and PHP block and I moved it to my frontblocks (in case that made a difference) and it's still blank.  I have to assume at this point it's user error (me :( ), but I'm not sure what I'm doing wrong.  Thanks for your help.  Nice site, BTW.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: Lesmond on January 10, 2007, 02:50:16 PM
I used a RSS front page block, and just placed the feed in,

QuoteNice site, BTW.
Thanks
Title: Re: RSS Feed Block - BUT, using PHP
Post by: makphisto on January 10, 2007, 03:00:09 PM
Yep, that's what I'm doing too.
I have a front page block (RSS feed) and I have this in the feed "box":
http://www.gijoefirefight.com/faq/feed/topten/rss.php

I checked permissions:
Show only titles: No
Do not allow block to collapse.
All membergroups are checked.

My TP Frontpage Settings show Front page blocks, and "Normal, frontblocks are shown alone".

And yet:
http://www.gijoefirefight.com/gijoetcg/index.php

I see an empty block.  You don't see something different by any chance?
Title: Re: RSS Feed Block - BUT, using PHP
Post by: Lesmond on January 10, 2007, 03:04:40 PM
yes I too see an empty block :(
I am no expert but I wonder if its because the feed is coming from your own site. maybe someone will come along with a better idea :)

Title: Re: RSS Feed Block - BUT, using PHP
Post by: Lesmond on January 10, 2007, 03:10:48 PM
Try this in a PHP block,
// An RSS Reader to grab news from whichever site you choose
$backend = "http://www.gijoefirefight.com/faq/feed/topten/rss.php"; //change this to match the rss feed url you wish to display.
// end


function endtheElement($parser, $tagName) {
// This function is used when an end-tag is encountered.
global $insideitem, $tag, $title, $description, $link;
 
  if ($tagName == "ITEM") {
    echo '<table width="100%" border="0"><tr>
      <td class="main-table">
      <span class="nav-head"><strong>
      ';
    printf("<p><b><a href='%s'>%s</a></b></p>", // make our title into an actual link
    trim($link),htmlspecialchars(trim($title))); // remove html characters from the title
 
    echo "</tr>";
    echo '<tr>
      <td class="nav">';
    printf("<p>%s</p>",$description); // Print out the live journal entry
    echo"</td>";
    echo "</tr>";
    echo "</table>";
    echo "<br>";
    $title = $description = $link = $insideitem = false;
   }
}

// Now to the parsing itself. Starts by creating it:

$xml_parser = xml_parser_create();

// Then setup the handlers:

xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

// Open the actual datafile:

$fp = fopen($backend, r);

// Run through it line by line and parse:

while ($data = fread($fp, 4096)) {
  xml_parse($xml_parser, $data, feof($fp))
    or die(sprintf("XML error: %s at line %d",
           xml_error_string(xml_get_error_code($xml_parser)),
           xml_get_current_line_number($xml_parser)));
}

// Close the datafile

fclose($fp);

// Free any memmory used

xml_parser_free($xml_parser);
Title: Re: RSS Feed Block - BUT, using PHP
Post by: makphisto on January 10, 2007, 03:21:30 PM
I tried that feed on another TP/SMF site of mine (with a different domain) and it doesn't work.

I tried your code, and it doesn't work - still a blank box.

Just out of curiousity, I tried this in a scriptbox (I've seen it work elsewhere):

<script language="JavaScript" src="http://www.gijoefirefight.com/faq/feed/topten/rss.php" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
for (count = 0; count < numHeadlines; count++) {
   document.write('<a href="' + link[count] + '" target=_blank>' + headline[count] + '</a><br>');
}
</script>


It didn't work.  I have a crappy host, I wonder if that's the problem.

Ahh well.  Thanks again.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: makphisto on January 15, 2007, 10:11:07 PM
Gah, this is driving me nuts. Anyone else want to take a stab at it?
Title: Re: RSS Feed Block - BUT, using PHP
Post by: knat on January 16, 2007, 08:54:58 AM
I use this RSS ticker on my site.. i try put in your feed and it worked fine.. so check it out.. it might be the solution you are looking for  ;)

http://www.dynamicdrive.com/dynamicindex17/rsstickerajax/index.htm

If you want to see a demo look here: http://www.gapeindex.dk/index.php?www;page=29 (no hardcore content on that page)

Mine only shows the title but it can also show date and description..

I use mine in an article but i am sure you can use it in a block also.

Good luck with it  ;)
Title: Re: RSS Feed Block - BUT, using PHP
Post by: TWD on February 18, 2007, 03:26:48 AM
I'm just starting to play around with RSS feeds and am trying to put one in a right-side block.  I have no idea what exactly I'm supposed to do, but I thought I just needed to give it the URL of the feed, which is this case is http://furmanpaladins.cstv.com/event-toolbar-rss.xml

Comes up blank.  I assume I'm doing something incredibly naive, because I really don't understand RSS.  Little help?
Title: Re: RSS Feed Block - BUT, using PHP
Post by: rider on February 18, 2007, 05:05:06 AM
You can try this.Admin>TP>block manager.Create a new block and choose the rss feed one.
You can try this link for rss feeds.
http://www.2rss.com/cat2_31.html

Just add the link in the block and call it whatever you want.
I have it set up on my site as just front page blocks.Click on my sig and see if thats what you're after.Hope this helps. :)
Title: Re: RSS Feed Block - BUT, using PHP
Post by: jdvarner on February 18, 2007, 05:24:51 AM
I must be doing something wrong. Everytime i do a feed box and put the feed url its just an empty box?
Title: Re: RSS Feed Block - BUT, using PHP
Post by: rider on February 18, 2007, 07:10:09 AM
Quote from: jdvarner on February 18, 2007, 05:24:51 AM
I must be doing something wrong. Everytime i do a feed box and put the feed url its just an empty box?
How is it set up?Do you have show titles only checked?Maybe that has something todo with it.try this.create a rss feed block and use this feed to see if it works.Its one from my site so I know it works.
http://sports.espn.go.com/espn/rss/news
Title: Re: RSS Feed Block - BUT, using PHP
Post by: knat on February 18, 2007, 07:22:49 AM
sometimes you have to put in www or the feed wont work in the reader.. even thoug it works fine in a browser some readers wants the www.. try that  ;)
Title: Re: RSS Feed Block - BUT, using PHP
Post by: jdvarner on February 18, 2007, 02:37:38 PM
I tried exactly what rider has a few posts up:

You can try this.Admin>TP>block manager.Create a new block and choose the rss feed one.
You can try this link for rss feeds.
http://www.2rss.com/cat2_31.html

It shows empty. im running tp 0.9.7 with smf1.1.1
Title: Re: RSS Feed Block - BUT, using PHP
Post by: jdvarner on February 18, 2007, 02:50:10 PM
Quote from: rider on February 18, 2007, 07:10:09 AM
Quote from: jdvarner on February 18, 2007, 05:24:51 AM
I must be doing something wrong. Everytime i do a feed box and put the feed url its just an empty box?
How is it set up?Do you have show titles only checked?Maybe that has something todo with it.try this.create a rss feed block and use this feed to see if it works.Its one from my site so I know it works.
http://sports.espn.go.com/espn/rss/news

didnt work? im sure im doing it just like you say. All i do is go to bloc manager. create bloc on left side. make it a rss block. and put in the link as you have it, and click save. i enable the block and its blank? im not messing with any of the default settings.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: rider on February 18, 2007, 03:48:42 PM
I noticed in your picture you have show titles only checked off as no.Have you tried it with yes checked off?
Title: Re: RSS Feed Block - BUT, using PHP
Post by: jdvarner on February 18, 2007, 03:55:02 PM
yes tried it. :)
Title: Re: RSS Feed Block - BUT, using PHP
Post by: hraylong on February 19, 2007, 04:39:24 AM
I am having the same problem getting a feed to display.  I can access the feed with a feed viewer, I tried Omega reader and with firefox and ie. 

This is the feed link : http://www.5thcolumn.info/killboard/?a=rss

I have it selected as the last block on the left side
Show Only Titles = no
Use Frame from Theme is selected
Allow block to collapse is selected

All member groups are able to see the feed.  You should be able to access the feed.  I have tried it with the www and without the www with the same result.

Does anyone have a suggestion?

Thanks

Ray
Title: Re: RSS Feed Block - BUT, using PHP
Post by: IchBin on February 19, 2007, 05:16:55 AM
jdvarner, there's an error in the XML feed. Try another one?

hraylong,
I have no problems displaying that feed. What version of SMF/TP etc are you using?
Title: Re: RSS Feed Block - BUT, using PHP
Post by: hraylong on February 19, 2007, 05:43:35 AM
SMF is 1.1.2.  I am finding out the Tiny Portal verison number.  What version are you using?  I did not setup the site.  I have just started doing some admin stuff to help a guy out.  Thanks for the quick reply.

Ray
Title: Re: RSS Feed Block - BUT, using PHP
Post by: softtouch_ph on February 19, 2007, 05:52:55 AM
I believe you have to set allow_url_fopen in php.ini to On in order to get feeds. I had the same issue, and that solved it.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: jdvarner on February 19, 2007, 02:58:35 PM
IchBin, i have tried every single feed in this thread. Even the ones folks say they have tested and they work.

Still blank box for the rss.

softtouch where is the set allow url fopen in php.ini? i would think if it was required to make changes like that it would be obvious across the board and proabably a read me somewhere on here regards it?

since im having so many issues with it, im assuming that aint the case.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: TWD on February 19, 2007, 03:51:27 PM
Quote from: softtouch_ph on February 19, 2007, 05:52:55 AM
I believe you have to set allow_url_fopen in php.ini to On in order to get feeds. I had the same issue, and that solved it.

That worked for me.  Really does need to be in a readme file or something, because I certainly never would have thought of it.

jdvarner - it was the second line in my php.ini file.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: Lesmond on February 19, 2007, 05:39:04 PM
You can make your own php.ini file, but be careful some host dont like it!
open notepad or similar, paste allow_url_fopen = On save as php.ini upload to your forum root, I have not tested this so use at your own risk!! 
test your rss feed ;)
Title: Re: RSS Feed Block - BUT, using PHP
Post by: hyem on April 26, 2007, 01:14:12 AM
Quote from: softtouch_ph on February 19, 2007, 05:52:55 AM
I believe you have to set allow_url_fopen in php.ini to On in order to get feeds. I had the same issue, and that solved it.

where can i find this file to change ? (the place of this file ?)
cause the rss didn't work for me too :(
Title: Re: RSS Feed Block - BUT, using PHP
Post by: IchBin on April 26, 2007, 01:19:09 AM
You'll need to ask your host that questions mate.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: hyem on April 26, 2007, 01:53:05 AM
Quote from: Lesmondâ„¢ on February 19, 2007, 05:39:04 PM
You can make your own php.ini file, but be careful some host dont like it!
open notepad or similar, paste allow_url_fopen = On save as php.ini upload to your forum root, I have not tested this so use at your own risk!! 
test your rss feed ;)

trying to create php.ini to forum root still won't work for me,.. I just migrate from joomla to TP, but i've los my rss link :'(
Title: Re: RSS Feed Block - BUT, using PHP
Post by: IchBin on April 26, 2007, 03:17:26 AM
Quote from: hyem on April 26, 2007, 01:53:05 AM
Quote from: Lesmondâ„¢ on February 19, 2007, 05:39:04 PM
You can make your own php.ini file, but be careful some host dont like it!
open notepad or similar, paste allow_url_fopen = On save as php.ini upload to your forum root, I have not tested this so use at your own risk!! 
test your rss feed ;)

trying to create php.ini to forum root still won't work for me,.. I just migrate from joomla to TP, but i've los my rss link :'(
This means that your host has probably turned the option for you to have a custom php.ini file off.
Title: Re: RSS Feed Block - BUT, using PHP
Post by: Sin69 on April 26, 2007, 03:58:50 AM
This might be of some use, I recently went from a dedicated box to a shared one, so I lost root access to the php.ini on the server.

My new host gave me the following option:

QuotePHP options can be enabled/disabled within the php.ini file in your hosting account. You or your web developer may like to upload their own php.ini. Here is how to get it working:

Create a plain-text file called .htaccess which is to be stored in your public_html directory. Inside this file, you should have:

suPHP_ConfigPath /home2/username/

Where 'username' is the username of your CPanel hosting account.
Upload your php.ini file into the root directory of your hosting account.

Note: With the php.ini file within the root directory, the PHP options you have enabled will be effective for your entire hosting account.

So it seems to be a 2 stage process where I also needed to add info to a .htaccess file.
If your host uses this method, it would be a matter of finding out what path to use.

Good luck with it!
Title: Re: RSS Feed Block - BUT, using PHP
Post by: hyem on April 26, 2007, 05:37:31 AM
yes thx,.. it's work now !!! thx.. alot..

but is there any trick to limiting content of our rss feed news