Aeonity Blog
Sponsored links
Help Topics

How can I add my Blog to my Website?


RSS feeds using XML is rather easy to setup, granted that you have an XML parser, and a template for the page… which is also quite easy to setup… infact, ive got an RSS feed on my site http://random-error.com/index.php?blog which is quite simple… just a couple of CSS layouts, and the include files…. Ok… now on to the good stuff.

**MAKE SURE PHP IS ENABLED ON YOUR WEBSITE!!!**

1. Go to http://magpierss.sourceforge.net and get her latest release of magpierss (this is the XML parser that is so nice… plus, its open source, and all you have to do is keep the files the same…)

2. now, create a subdirectory called rss under where the index.php file is to call up the script to display the RSS feed. this way, it keeps all the files separate and nice looking…

3. ok, you’ve got the directory? Good. Extract the gzip into the directory, and you should get a list of files like this…..

Code:
<\RSS\extlib>                                                                                                   <dir>
<\RSS\htdocs>                                                                                                   <dir>
<\RSS\scripts>                                                                                                  <dir>
1. \RSS\AUTHORS                                                                                                    28
2. \RSS\ChangeLog                                                                                               6,989
3. \RSS\CHANGES                                                                                                   965
4. \RSS\cookbook                                                                                                3,032
5. \RSS\INSTALL                                                                                                   737
6. \RSS\NEWS                                                                                                    1,863
7. \RSS\README                                                                                                  1,301
8. \RSS\rss_cache.inc                                                                                           5,249
9. \RSS\rss_fetch.inc                                                                                          12,679
10. \RSS\rss_parse.inc                                                                                         14,593
11. \RSS\rss_utils.inc                                                                                          1,847
12. \RSS\TROUBLESHOOTING                                                                                        

the important files are these 4
rss_cache.inc
rss_fetch.inc
rss_parse.inc
rss_utils.inc

really, the rest of the stuff you can get rid of, but keep the subdirectories, and the contents, they will be used.

The files you do need are: (there are 6) the directorys require ALL Files under them to be there to work.
<extlib>
<htdocs>
rss_cache.inc
rss_fetch.inc
rss_parse.inc
rss_utils.inc

4. go to your fancy web editor (notepad.exe works…) and type this in….
Code:
<html>
<head><title>MY fancy RSS FEED</title></head>
<body>
<table><tr><td>My RSS FEED</td></tr>
now heres the fun PHP that you need to have…. (this goes infront of the <html> tag….
Code:
<?php
define('MAGPIE_DIR', 'rss/');
require_once(MAGPIE_DIR.'rss_fetch.inc');
$url = "*YOUR RSS FEED HERE IN URL FORMAT SMART ONE";
?>     

YOU NEED TO CHANGE THESE VARIABLES!!!
change $url to the URL of your blog RSS feed, most likely 
"http://emoblog.com/rss.php?user="

do this by taking 
$url = "*YOUR RSS FEED HERE IN URL FORMAT SMART ONE";
and editing it to
$url = "http://emoblog.com/rss.php?user=(YOUR EMOBLOG USER NAME HERE)";


now put this after the body tag
Code:
 <?php
$rss = fetch_rss( $url );
echo slashbox ($rss);
?>
so the code should look like this
Code:
<?php
define('MAGPIE_DIR', 'DIRECTORY WHERE YOU PUT magpierss into (should be rss/)');
require_once(MAGPIE_DIR.'rss_fetch.inc');
$url = "*YOUR RSS FEED HERE IN URL FORMAT SMART ONE";
?> <html>
<head><title>MY fancy RSS FEED</title></head>
<body>
<?php
$rss = fetch_rss( $url );
echo slashbox ($rss);
?></body></html>

5. now to setup the repeating mask for the XML parser to display shit into….

This is put after the </html> tag… so it wont screw up the display course….
This is the simple example code found in scripts, and its been modified a bit… but yeah, the thing is the same idea….
Code:
<?php

# just some quick and ugly php to generate html
#
#
function slashbox ($rss) {
	echo "<div id='blogbox'>";
	echo "<div id='titlebox'>";
	
	# get the channel title and link properties off of the rss object
	#
	$title = $rss->channel['title'];
	$link = $rss->channel['link'];
	
	echo "<a href=$link>$title</a>";
	echo "</div>";
	
	# foreach over each item in the array.
	# displaying simple links
	#
	# we could be doing all sorts of neat things with the dublin core
	# info, or the event info, or what not, but keeping it simple for now.
	#
	foreach ($rss->items as $item ) {
		echo "<div id='titletxt'>";
		echo "<a href=$item[link]>";
		echo $item['title'];
		echo "</a></div>";
		echo "<div id='blogcontent'>";
		echo $item['description'];
		echo "</div>";
	}		
	
	echo "</div>";
}

?>

this will display basically this….
http://random-error.com/blog.php

no formatting, because there is no CSS linked to the file, that can be taken care of by writing a css style sheet, and linking it, or by putting it into the index.php of your site that you used to include the blog into (if you do that for the website making content load a lot faster, and taking up less problems…)

with the CSS enabled, you see this

http://random-error.com/index.php?blog

basically that’s how its done… the ending code for the page should look like this….
Code:
<?php

define('MAGPIE_DIR', 'EDIT THIS');
require_once(MAGPIE_DIR.'rss_fetch.inc');
$url = "EDIT THIS";
?>

<html>
<body>

<?php
$rss = fetch_rss( $url );
echo slashbox ($rss);
?>

</body>
</html>
<?php

# just some quick and ugly php to generate html
#
#
function slashbox ($rss) {
	echo "<div id='blogbox'>";
	echo "<div id='titlebox'>";
	
	# get the channel title and link properties off of the rss object
	#
	$title = $rss->channel['title'];
	$link = $rss->channel['link'];
	
	echo "<a href=$link>$title</a>";
	echo "</div>";
	
	# foreach over each item in the array.
	# displaying simple links
	#
	# we could be doing all sorts of neat things with the dublin core
	# info, or the event info, or what not, but keeping it simple for now.
	#
	foreach ($rss->items as $item ) {
		echo "<div id='titletxt'>";
		echo "<a href=$item[link]>";
		echo $item['title'];
		echo "</a></div>";
		echo "<div id='blogcontent'>";
		echo $item['description'];
		echo "</div>";
	}		
	
	echo "</div>";
}

?>

Need help? Visit our Troubleshooting Support Forum

Did this help you?
Click no to contact Aeonity.
Great! Click yes to go back the help section.