Jump to content
Killersites Community
Sign in to follow this  
Mick

Misc PHP to Load XML Data doesn't work

Recommended Posts

Greetings!

 

In Misc PHP Videos, "Use PHP, jQuery & AJAX to Load XML Data Part 1",

the RSS feed that Ben uses is "http://killersites.com/forums/feed/rss/".

With all the great changes at Killersites, this URL is no longer valid.

 

Can this video be carried out with another Killersites Forum RSS? If so,

which one? Do any more changes need to be made from the instructions in

the video?

 

Here is the beginning code to test being able to obtain the feed file:

 

<?php

$file = "http://killersites.com/forums/feed/rss/";

$xml = simplexml_load_file($file);

 

echo "<pre>";

print_r($xml);

echo "</pre>";

?>

 

Once that works, the echo/print/echo statements are removed, and each rss

item is made part of a list with this code:

 

echo "<ul>";

foreach($xml->channel->item as $item) {

echo "<li><a href='$item->link'>$item->title</a></li>";

}

echo "</ul>";

 

Capturing the Killersites RSS Forum feed seems like a really cool thing to do.

Perhaps if someone can help me figure it out, I can set up an affiliate marketer

web page for selling Killersite Store DVDs. I think the courses are fantanstic,

and I highly recommend them.

Share this post


Link to post
Share on other sites

Ben,

 

Thanks so much for a fast reply! Yes, that RSS feed works.

 

Students, here are my

Tips for Doing the "Use PHP, jQuery & AJAX to Load XML Data" Project:

 

After struggling for a few hours, mostly over careless errors,

such as a missing > and using #recenttopics in one place and

#recentTopics in another, and writing text/javascript instead

of text/css for the style tag for loading the animated gif, and

for forgetting an occasional semicolon, I got it to work!

 

You need to go to the jQuery site and download the script--

the minimized version is small. You have to go to ajaxload.info

and download an animated gif. I spend far too much time deciding

and getting hypnotized by the swirling animations.

 

You have to match names. The jQuery script should be renamed jquery.js,

or, alternatively, you can match the name used in index.php to the actual

file name.

 

The animated gif name at the time of this post is ajax-loader.gif. Whatever

name you get, it has to match your code.

 

I found the size Ben used was too small for the gif, and so increased the

height and width to 30px each. (Since it is a circle in a square, height

should equal width.) I used Killersites green for my gif color and a

transparent background.

 

Of course make sure the four files are in the same folder. You may want

to create a special folder just for this project. The 4 files are jquery.js,

index.php, getforum.php, and ajax-loader.gif. And use an RSS feed that works!

(See Ben's post above this one.)

 

For every class: Follow along with the instrucor, and test as you go.

You aren't going to learn nearly as much by passively watching videos

as you will learn by DOING each step!

 

This part did not work. Here's my work around.

The code in index.php to use addClass() did not work for me.

My solution:

  1. Remove the statement (the whole line) where addClass("loading")
    appears in the head, javascript section.
  2. Add class="loading" to div id=recentTopics
  3. Add an anchor text to class="loading" with href = the file name of your gif

The loading gif disappeared as soon as the list appeared, as it is supposed to.

This is because the code Ben gave for removeClass() as a sub-function of

getforum.php remains in place.

 

Thank you Ben for a Great Segment. Thank you Stephan for Excellent Teaching and the idea to have Ben share.

It is such a thrill to get something "complicated" to work. My heart tingled

when I saw the RSS feed of posts appear and then again when the animated gif

code finally worked. Even though we were mostly spoon-fed, it's a great pleasure

to code and see correct results. I hope that even when I become an "old timer",

that I still derive a bit of excitement upon successfully completing a coding project.

Thank you for providing a gateway to make this a career, and for the superb teaching!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×