Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Regular Coder YaymeQ's Avatar
    Join Date
    Feb 2008
    Location
    virginia
    Posts
    140
    Thanks
    14
    Thanked 0 Times in 0 Posts

    RSS Feeds - General how-to question

    Okay, I know the thing about googling my question before posting and it's probably right in front of my face but I don't know what I'm talking about so searching for it isn't helping. I know how to subscribe and all that for personal use but what I want to do, is have it on the site I'm making. I want a news area people can go to on my site that displays an rss feed I've subscribed to. Is that possible? Like "My Yahoo" displays the feeds I pick and all I have to do is go there. Or is that a module? (What is a module anyway?) Only I don't want them to customize it I just want a news area on my site that's automatically updated for me. That's it.
    Where is the "any" key??!

  • #2
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post
    An RSS feed is essentially an Xml file which contains certain fields in a certain format - that's it.

    Have a look at the specifications to see the formats available.

    All you have to do is basically print out your news items or whatever according to the RSS format, make sure the response content-type of the page is set to "application/xml" (there might be an rss-specific mime-type, i don't know) and you're good to go.

    Since there are a few different formats you might want to choose to adhere to v2 and send it across to Feedburner which I believe standardises the output a bit so it can reach the majority of readers out there, aswell as giving you some nice stats.

    Hope that gives you a start.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts
    There's a large number of scripts on the web to do this for you. Sorta plug em' in and they do the work.
    Try googling RSS Static
    then Zebrafeeds by Laurent Cazalet
    Even more complex, My Headlines by Mike Agar
    PHPClasses.org also has some
    Google's developer section has a nice one that's not so hard to customize
    There's alot out there

    I'd recommend Zebrafeeds.
    MyHeadlines gives people headaches installing, no doubt. However it's setup wonderfully and in my opinion he's coverred most every use you could have for RSS including offerring your combined feeds as one single feed for others to use in their newsreaders(besides seeing it on the site) I'm guessing his site is jmagar.com

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,518
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    YaymeQ ...

    It's actually very easy to do.
    Give me a URL for a feed you want to use on your site,
    then I'll give you a simple working example.

    (and are you using PHP5?)

  • #5
    Regular Coder YaymeQ's Avatar
    Join Date
    Feb 2008
    Location
    virginia
    Posts
    140
    Thanks
    14
    Thanked 0 Times in 0 Posts
    http://www.washingtonpost.com/wp-dyn...tate/index.xml

    I don't know if that's the one I'll end up using but it'll work for the purpose of demonstration.

    as far as using php5 ... at the moment I'm not using anything. Well, besides html/css but that's a given.
    Last edited by YaymeQ; 02-14-2008 at 05:24 PM. Reason: fixed typo
    Where is the "any" key??!

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,518
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    I assume your webhost allows PHP scripting?

    You'll need to change the extension to .php
    Example "index.php" instead of "index.html"

    I'm working on an example for the feed.

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,518
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    You will stick the code below into the area on your page where the feed will appear.
    I deliberately did no formatting for the text, because it will be using your own CSS
    for the <div> or <table> where you place the code.

    Your page needs to have the extension of .php ... or you need to have your .html
    extensions processed as PHP (ask your webhost about that).

    Here is my working example:
    http://www.catpin.com/yaymeq.php

    Here is the PHP script:
    PHP Code:
    <?php  
    // rss page for Washington Post -  
    $feed_url "http://www.washingtonpost.com/wp-dyn/rss/realestate/index.xml";  

    # INITIATE CURL. 
    $curl curl_init(); 

    # CURL SETTINGS. 
    curl_setopt($curlCURLOPT_URL,"$feed_url"); 
    curl_setopt($curlCURLOPT_RETURNTRANSFER1); 
    curl_setopt($curlCURLOPT_CONNECTTIMEOUT0); 

    # GRAB THE XML FILE. 
    $xmlTwitter curl_exec($curl); 

    curl_close($curl); 

    # SET UP XML OBJECT.
    # Use either one of these, depending on revision of PHP.
    # Comment-out the line you are not using.
    //$xml = new SimpleXMLElement($xmlTwitter);
    $xml simplexml_load_string($xmlTwitter); 

    // How many items to display 
    $count 5

    // How many characters from each item 
    // 0 (zero) will show them all. 
    $char 200

    foreach (
    $xml->channel->item as $item) { 
    if(
    $char == 0){ 
    $newstring $item->description

    else{ 
    $newstring substr($item->description0$char); 

    if(
    $count 0){ 
    //in case they have non-closed italics or bold, etc ... 
    echo"</i></b></u></a>\n"
    echo

    <div style='font-family:arial; font-size:.8em;'>  
    <b>{$item->title}</b><br />  
    $newstring ... <a href='{$item->guid}'>read more</a> 
    <br /><br /> 
    </div> 
    "
    ;  

    $count--; 
    }  
    ?>

  • Users who have thanked mlseim for this post:

    YaymeQ (02-14-2008)

  • #8
    Regular Coder YaymeQ's Avatar
    Join Date
    Feb 2008
    Location
    virginia
    Posts
    140
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Hey thanks! Yes my webhost allows php scripting I just don't know anything about it, besides recognizing comments, so I tend to not mess with it ... yet anyway. My site has to be up by saturday so after that I'm going to try to learn a bit more so I'm not stumbling through this so much. Thank you so much!
    Where is the "any" key??!

  • #9
    Regular Coder YaymeQ's Avatar
    Join Date
    Feb 2008
    Location
    virginia
    Posts
    140
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Oh! and if I save my html file as a php file all the html will still be read as html right? So it'll still display like the rest of the pages?
    Where is the "any" key??!

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,518
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Save a copy of your original .html file.

    Make a new copy and change the extension to .php
    Put the script I gave into a spot on the new page (inside your <table> or <div>).
    Include the <?php and ?> part of the script when you insert it.

    Upload your new .php file and enter URL by it's new name (mypage.php ... or whatever).

    It will either work or not, depending on the version of PHP your webhost uses.
    If they are using PHP4, I don't think the CURL functions will work.

    I realize this whole POST should be in the PHP part of this forum, but I cannot
    move it (I'm not a moderator). Anyhow, others might find it useful.

    EDIT:
    and if it works, let us see your website.

    .
    Last edited by mlseim; 02-14-2008 at 06:56 PM.

  • #11
    Regular Coder YaymeQ's Avatar
    Join Date
    Feb 2008
    Location
    virginia
    Posts
    140
    Thanks
    14
    Thanked 0 Times in 0 Posts
    yeah sorry about that, I hadn't realized this was going to end up as a php post. Just some followup info, my host does use php 5 but it has to be saved as .php5 not .php or it will automatically read as php4 (Just got done checking the faq).

    Edit: My website isn't up yet, I have a placeholder there right now, I'm just testing to make sure everything works before I make it live. but in a few days I can come back and let you know.
    Where is the "any" key??!

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,518
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    extension of .php5 is fine.

    You can also ask them about processing all of your .html files as .php5
    so you don't need to worry about extensions.

    Keep in mind that once you have a .php file, you can't view it offline
    like a normal .html file. PHP is processed by your server (webhost), not
    on your PC.

    That's why I mentioned making a "saved" copy of your original .html file,
    in case you're using Dreamweaver or something to create your html pages.

    You'll soon realize the power of PHP and be hooked on it ... dynamically
    generating pages without the trouble of static .html pages.
    Content management is what it's all about.

  • #13
    Regular Coder YaymeQ's Avatar
    Join Date
    Feb 2008
    Location
    virginia
    Posts
    140
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Well, actually I'm hand coding everything. I realize I could use some type of wysiwyg editor but I tried it and the code is unreadable to me. I have go-live but I also want to actually learn the coding languages better. So no dreamweaver. I'm hoping php will be as easy as html was to pick up, but I'll do that after my deadline. The site looks really amaturish right now but I'm not sure how to make it look better, later I'll go to the "review my site" section and see what people say. lol I'm anticipating a lot of CC. hopefully.
    Where is the "any" key??!

  • #14
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,518
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Hand-coding is best.

    As for the RSS reader....

    If you just take the script above and save it as "yaymeq.php5"
    and upload it, you should be able to see the same thing
    as my test: http://www.catpin.com/yaymeq.php

    You of course would use your own domain name ...

    That would tell you if it's working and PHP5 is configured OK.

    For your "amateurish" site, if you have a copyright date on
    the bottom of your page, you can change 2008 to <?=date("Y")?>
    It will always show the current year and switch to 2009 automatically.

    That's the power of PHP.
    Last edited by mlseim; 02-14-2008 at 10:20 PM.

  • #15
    Regular Coder YaymeQ's Avatar
    Join Date
    Feb 2008
    Location
    virginia
    Posts
    140
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Okay I know it's been a while but it you go to http://webuynovahouses.com/realestatenews.php5

    I only copied and pasted the code because I don't know php yet (I got a book though!) so you see that error ... how do I fix that?

    Code:
    foreach ($xml->channel->item as $item) { 
    if($char == 0){ 
    $newstring = $item->description; 
    }
    That's the piece of code it deals with.

    EDIT:
    stupid question ... I fixed it ... bad url ... eh heh heh

    but you still said you wanted to see the site! So there it is!
    Last edited by YaymeQ; 03-19-2008 at 01:37 AM. Reason: fixed
    Where is the "any" key??!


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •