Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Iron Speed
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 29th, 2002, 09:52 AM
houtan houtan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 18 houtan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
syndication of articles

Greetings,
i am using a phpnuke script and as you might be knowing it has a builtin backend.php file thru which others can syndicate our articles. but i wanted something where even a html based site could syndicate our articles something like your site is providing. any suggestion and help in how to go ahead with that is appreciated.

thanx

Reply With Quote
  #2  
Old May 29th, 2002, 10:33 AM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Hi,
Well it's a really simple process. First, you create a PHP script on your server that outputs only JavaScript commands.

For example, to output the text "hello", you would use a PHP script like this

<?php

// Start the output
?>

document.write("hello");

<?php

// End output
?>

Obviously you would loop through the articles on your server and use the JavaScript document.write funciton to output a whole bunch of document.write lines to form HTML tables, etc. Make sure you escape ' with \' and " with \".

Once you've done the PHP script that outputs JavaScript, let the client call it like this:

<script language="JavaScript" src="http://www.yoursite.com/feed.php"></script>

that's really all there is to it. If you need any help, just reply to this post.

Reply With Quote
  #3  
Old May 29th, 2002, 02:35 PM
houtan houtan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 18 houtan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi mitch,

i am clueless as what u meant in the earlier post..
anyway i am pasting the backend.php file..

-------------------------------
<?php

/************************************************** **********************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve) */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************** **********************/

include("extention.inc");
include("mainfile.$phpEx");
header("Content-Type: text/plain");
$result = mysql_query("SELECT sid, title, time FROM ".$mpnTables['stories']." ORDER BY sid DESC limit 10");
if (!result) {
echo "An error occured";
} else {
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n";
echo " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n";
echo "<rss version=\"0.91\">\n\n";
echo " <channel>\n";
echo " <title>$sitename</title>\n";
echo " <link>$nuke_url</link>\n";
echo " <description>$backend_title</description>\n";
echo " <language>$backend_language</language>\n\n";
echo " <image>\n";
echo " <title>$sitename</title>\n";
echo " <url>$backend_image</url>\n";
echo " <link>$nuke_url</link>\n";
echo " <description>$slogan</description>\n";
echo " <width>$backend_width</width>\n";
echo " <height>$backend_height</height>\n";
echo " </image>\n\n";
for ($m=0; $m < mysql_num_rows($result); $m++) {
list($sid, $title, $time) = mysql_fetch_row($result);
echo " <item>\n";
echo " <title>$title</title>\n";
echo " <link>$nuke_url/article.$phpEx?sid=$sid</link>\n";
echo " </item>\n\n";
}
echo " </channel>\n\n";
echo "</rss>";
}

?>
-------------------------------------------

other phpnuke sites can syndicate our articles by adding site.com/backend.php in their headline box.( an option in phpnuke)

Now what i wanted is something as easy as your javascript code. where others could syndicate with those lovely tabled formatting

pls guide me as how to do that. also will the syndicated articles change as we add new articles to our sites?

thanx for your time

Reply With Quote
  #4  
Old May 29th, 2002, 06:10 PM
PabstER PabstER is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 26 PabstER User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well I guess the best way to learn something is to see how it works, so here's the code for our content feed:

<?php

$result = mysql_query("select id, title from articles order by id desc limit 10");
?>

document.write('<a href="http://www.devarticles.com">');
document.write('<img border="0" src="http://www.devarticles.com/logo_small.gif">');
document.write('</a>');
document.write('<table border="1" bordercolor="#FF7300" width="150" cellspacing="0" cellpadding="0">');
document.write('<tr>');
document.write('<td bgcolor="#FF7300" height="21">');
document.write('<p style="margin-left:5">');
document.write('<font face="verdana" size="1" color="white">');
document.write('<b>Recent Articles</b>');
document.write('</font>');
document.write('</td>');
document.write('</tr>');

<?php

while($row = mysql_fetch_array($result))
{
$title = $row["title"];
$url = "http://www.devarticles.com/art/1/" . $row["id"];
?>
document.write('<tr>');
document.write('<td bgcolor="#FFEFCE" onMouseOver="this.style.backgroundColor=\'#FFFFC0\'" onMouseOut="this.style.backgroundColor=\'#FFEFCE\'">');
document.write('<p style="margin-top:5; margin-bottom:5; margin-left:10; margin-right:10">');
document.write('<a target="_blank" href="<?php echo $url; ?>">');
document.write('<font face="verdana" color="black" size="1">');
document.write('<?php echo str_replace("'", "\'", $title); ?>');
document.write('</font>');
document.write('</a>');
document.write('</td>');
document.write('</tr>');
<?php
}
echo "document.write('</table>');";
?>

Of course there is database connection code and I have renamed the tables, etc but that's our code! Call the file above something like myfeed.php. Now, to call it from any client:

<script language="JavaScript" src="http://www.yoursite.com/myfeed.php"></script>

Obviously you'll need to create an articles table with a title and id field, as well as the MySQL connect code in the script above, etc, but that shouldn't be too hard to follow...

Reply With Quote
  #5  
Old May 29th, 2002, 07:42 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Just an idea, you could use iframes?? just load the content page in the frame. i dont know if this would be faster or not tho?

Reply With Quote
  #6  
Old May 30th, 2002, 04:37 PM
houtan houtan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 18 houtan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well this is the table structure..

#
# Table structure for table `mpn_stories`
#

CREATE TABLE mpn_stories (
sid int(11) NOT NULL auto_increment,
catid int(11) NOT NULL default '0',
aid varchar(30) NOT NULL default '',
title varchar(80) default NULL,
time datetime default NULL,
hometext text,
bodytext text NOT NULL,
comments int(11) default '0',
counter mediumint(8) unsigned default NULL,
topic int(3) NOT NULL default '1',
informant varchar(20) NOT NULL default '',
notes text NOT NULL,
ihome int(1) NOT NULL default '0',
PRIMARY KEY (sid),
KEY idxstoriessiddesccatid (sid,catid),
KEY idxstoriessiddesc (sid),
KEY idxstoriessiddesctopic (sid,topic),
KEY idxstoriessiddescihomecatid (sid,ihome,catid),
KEY idxstoriestime (time),
KEY idxstoriescounterdesctopic (counter,topic),
KEY idxstoriescounterdesctime (counter,time),
KEY idxstoriescatid (catid),
KEY idxstoriesiddescinformant (sid,informant),
KEY idxstoriesaid (aid),
KEY idxstoriestopic (topic),
KEY idxstoriescounterdesc (counter),
KEY idxstoriescommentsdesc (comments)
) TYPE=MyISAM;

Reply With Quote
  #7  
Old May 30th, 2002, 04:40 PM
houtan houtan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 18 houtan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
and this is the feed.php file

<?php
header("Content-Type: text/javascript");

$db_server = "localhost";
$db_db = "mynuke";
$db_user = "fakeuser";
$db_pass = "fakepassword";

@$sConn = mysql_connect($db_server, $db_user, $db_pass);
@$dConn = mysql_select_db($db_db, $sConn);

if(!$sConn || !$dConn)
{
?>
document.write("Couldn't load news");
<?php
}

?>

$nResult = mysql_query("SELECT sid, title, time FROM ".$mpnTables['stories']." ORDER BY sid DESC limit 10");
?>

document.write('<a href="http://www.site.com">');
document.write('<img border="0" src="http://www.site.com/logo_small.gif">');
document.write('</a>');
document.write('<table border="1" bordercolor="#FF7300" width="150" cellspacing="0" cellpadding="0">');
document.write('<tr>');
document.write('<td bgcolor="#FF7300" height="21">');
document.write('<p style="margin-left:5">');
document.write('<font face="verdana" size="1" color="white">');
document.write('<b>Recent Articles</b>');
document.write('</font>');
document.write('</td>');
document.write('</tr>');

<?php

while($row = mysql_fetch_array($nResult))
{
$title = $row["title"];
$url = "http://localhost/mynuke/article.php?" . $row["sid"];
?>
document.write('<tr>');
document.write('<td bgcolor="#FFEFCE" onMouseOver="this.style.backgroundColor='#FFFFC0'" onMouseOut="this.style.backgroundColor='#FFEFCE'">');
document.write('<p style="margin-top:5; margin-bottom:5; margin-left:10; margin-right:10">');
document.write('<a target="_blank" href="<?php echo $url; ?>">');
document.write('<font face="verdana" color="black" size="1">');
document.write('<?php echo str_replace("'", "'", $title); ?>');
document.write('</font>');
document.write('</a>');
document.write('</td>');
document.write('</tr>');
<?php
}
echo "document.write('</table>');";
?>

Reply With Quote
  #8  
Old May 30th, 2002, 04:45 PM
houtan houtan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 18 houtan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
first, thanx to both of you for helping me out and secondly sorry for posting in installments, this thing never allowed me to post at one full time

anyway those are the above two files which i have and it is not working pls lemme know where i have gone wrong. and any suggestion is appreciated. it is very important to me ..

thanx in advance again..

Mitch are you listening. help me out , also PabstER

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > syndication of articles


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway