Author |
Message |
pellow
New Member


Joined: Aug 16, 2005
Posts: 3
|
Posted:
Tue Aug 16, 2005 3:16 pm |
|
Hi
I have a phpnuke-website in Denmark - Only registered users can see links on this board! Get registered or login! - We write all content in "content module". It works great for us.
My problem is that I would like to make RSS feed for the site. Just like backend.php. How can I use content instead of news?
poul erik |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Wed Aug 17, 2005 7:52 am |
|
So you want to just feed the content titles? |
|
|
|
 |
pellow

|
Posted:
Wed Aug 17, 2005 7:59 am |
|
Yes - thats all I need. Do you think you can help me?
regards
pel |
|
|
|
 |
Raven

|
Posted:
Wed Aug 17, 2005 8:00 am |
|
Sure. Let me whip something up and I'll post back. |
|
|
|
 |
Raven

|
Posted:
Wed Aug 17, 2005 11:25 pm |
|
Code:<?php
/************************************************************************
* PHP-NUKE: Advanced Content Management System *
* ============================================ *
* Copyright (c) 2002 by Francisco Burzi *
* 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. *
*************************************************************************
* Additional coding modifications by Raven 2005-08-17 *
* Script Name: backend-content.php *
* Author : Gaylen Fraley (aka Raven) *
* Support : http://ravenphpscripts.com -- http://ravenwebhosting.com *
* Purpose : Create an RSS feed for the Contents Pages *
* Usage : Place in Nuke folder (where mainfile.php is) and run it. *
* *
* This is a standards compliant valid RSS feed according to the *
* RSS Feed Validator at http://www.feedvalidator.org/ *
*************************************************************************
* Based on the following Schema *
*************************************************************************
CREATE TABLE nuke_pages (
pid int(10) NOT NULL auto_increment,
cid int(10) NOT NULL default '0',
title varchar(255) NOT NULL default '',
subtitle varchar(255) NOT NULL default '',
active int(1) NOT NULL default '0',
page_header text NOT NULL,
text text NOT NULL,
page_footer text NOT NULL,
signature text NOT NULL,
date datetime NOT NULL default '0000-00-00 00:00:00',
counter int(10) NOT NULL default '0',
clanguage varchar(30) NOT NULL default '',
PRIMARY KEY (pid),
KEY pid (pid),
KEY cid (cid)
) TYPE=MyISAM;
CREATE TABLE nuke_pages_categories (
cid int(10) NOT NULL auto_increment,
title varchar(255) NOT NULL default '',
description text NOT NULL,
PRIMARY KEY (cid),
KEY cid (cid)
) TYPE=MyISAM;
*************************************************************************/
$rssFeedLimit = 15; // Maximum lines in feed
$slf = "\n"; //Single line feed
$dlf = "\n\n"; //Double line feed
require_once('config.php');
require_once('db/db.php');
$row = $db->sql_fetchrow($db->sql_query('SELECT sitename, nukeurl, backend_title, backend_language FROM '.$user_prefix.'_config'));
$sitename = $row['sitename'];
$nukeurl = $row['nukeurl'];
$backend_title = $row['backend_title'];
$backend_language = $row['backend_language'];
header('Content-Type: text/xml');
$result = $db->sql_query('SELECT pid, title FROM '.$user_prefix.'_pages WHERE active=1 ORDER BY date DESC LIMIT '.$rssFeedLimit);
$rssFeed = '';
$rssFeed .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>".$dlf
. "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"".$slf
. " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">".$dlf
. "<rss version=\"0.91\">".$dlf
. '<channel>'.$slf
. '<title>'.htmlspecialchars($sitename).'</title>'.$slf
. '<link>'.$nukeurl.'</link>'.$slf
. '<description>'.htmlspecialchars($backend_title).'</description>'.$slf
. '<language>'.$backend_language.'</language>'.$slf
;
while ($row = $db->sql_fetchrow($result)) {
$title = str_replace('_',' ',$row['title']);
$rssFeed .= '<item>'.$slf
. '<title>'.htmlspecialchars($title).'</title>'.$slf
. '<link>'.$nukeurl.'/modules.php?name=Content&pa=showpage&pid='.intval($row['pid']).'</link>'.$slf
. '</item>'.$dlf
;
}
$rssFeed .= '</channel>'.$slf
. '</rss>'
;
echo $rssFeed;
?>
|
|
|
|
|
 |
pellow

|
Posted:
Thu Aug 18, 2005 12:34 am |
|
Thank you
Super - just what I needed.
Next qustion - Is it possible to show: Headline an maybe also the first 30 words??
Don't missunderstand Im så thankfull for what you have made. But just if had an ides.
Best regards from Denmark
Poul Erik |
|
|
|
 |
Raven

|
Posted:
Thu Aug 18, 2005 1:16 am |
|
Replace this section of code
After header('Content-Type: text/xml');Code:$result = $db->sql_query('SELECT text, pid, title FROM '.$user_prefix.'_pages WHERE active=1 ORDER BY date DESC LIMIT '.$rssFeedLimit);
$rssFeed = '';
$rssFeed .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>".$dlf
. "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"".$slf
. " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">".$dlf
. "<rss version=\"0.91\">".$dlf
. '<channel>'.$slf
. '<title>'.htmlspecialchars($sitename).$slf.substr(0,30,$text).'</title>'.$slf
. '<link>'.$nukeurl.'</link>'.$slf
. '<description>'.htmlspecialchars($backend_title).'</description>'.$slf
. '<language>'.$backend_language.'</language>'.$slf
;
while ($row = $db->sql_fetchrow($result)) {
$title = str_replace('_',' ',$row['title']);
$text = strip_tags(substr($row['text'],0,30));
$rssFeed .= '<item>'.$slf
. '<title>'.htmlspecialchars($title).'</title>'.$slf
. '<link>'.$nukeurl.'/modules.php?name=Content&pa=showpage&pid='.intval($row['pid']).'</link>'.$slf
. '<description>'.$text.'</description>'.$slf
. '</item>'.$dlf
;
}
| Before $rssFeed .= '</channel>'.$slf
. '</rss>'
;
echo $rssFeed; |
|
|
|
 |
NoFantasy
Worker


Joined: Apr 26, 2005
Posts: 114
|
Posted:
Fri Jul 28, 2006 9:23 am |
|
...would it be possible (in an easy way) to join data from other tables aswell? Make it feed from several tables, not only content (or news for that matter), showing 15 latest items all together sorted by date? |
|
|
|
 |
Raven

|
Posted:
Fri Jul 28, 2006 9:37 am |
|
|
|
 |
NoFantasy

|
Posted:
Fri Jul 28, 2006 10:04 am |
|
Hehe, well...any hint that could guide me in the right direction? When it comes to sql im kinda stuck.
Create a temporary table, select data from various tables, insert into temp table...and grab the data from temp table?
Ok, i admit im a bit stuck on this, sql isn't my major skill. If any has a chance leading me in the right direction i'd appreciate it. |
|
|
|
 |
Raven

|
Posted:
Fri Jul 28, 2006 10:18 am |
|
You have to SELECT the data from your tables and JOIN them in a WHERE clause that equates like columns from each table. I really don't have the time to give you an SQL 101 course much more than that. Visit the MySQL on line documentation for examples at http://www.mysql.com . Also, get a good book on MySQL. There are several of them out there but I recommend MySQL by Dubois - Third Edition. You don't need a temp table either  |
|
|
|
 |
NoFantasy

|
Posted:
Fri Jul 28, 2006 10:23 am |
|
Ty Sir, at least now i have a clue where to start, what to look for and what to not look for. |
|
|
|
 |
NoFantasy

|
Posted:
Sun Aug 06, 2006 10:17 am |
|
...well, i managed to achieve what i wanted, this will "feed" from more than one table and display the newest content from five different sections all linked to the correct page:
Code:
$content = "<a n*ame=\"sc*rollingcode\"></a><m*arquee be*havior=\"scroll\" align=\"center\" direction=\"left\" height=\"14\" sc*rollamount=\"3\" sc*rolldelay=\"0\" on*mouseover=\"this.*scrollAmount=2\" on*mouseout=\"this.*scrollAmount=5\">";
$content .="<b>Newest Content:</b> ";
$sql = "(SELECT t.sid, t.title, t.time, 1 as n
FROM nuke_stories t
ORDER BY t.time DESC
LIMIT 4)
UNION
(SELECT t.sid, t.subject, t.date, 2 as n
FROM nuke_comments t
ORDER BY t.date DESC
LIMIT 4)
UNION
(SELECT t.rid, t.pagename, t.date, 3 as n
FROM nuke_MReviews t
ORDER BY t.date DESC
LIMIT 4)
UNION
(SELECT t.lid, t.title, t.date, 4 as n
FROM nuke_downloads_downloads t
ORDER BY t.date DESC
LIMIT 4)
UNION
(SELECT t.pid, t.title, t.date, 5 as n
FROM nuke_pages t
WHERE active=1
ORDER BY t.date DESC
LIMIT 4)
ORDER BY time DESC
LIMIT 15";
$result = $db->sql_query($sql);
while (list($id, $title, $date, $n) = $db->sql_fetchrow($result)) {
$title = stripslashes($title);
if ($n==1) {
$content.="News: <a href=\"modules.php?name=News&file=article&sid=$id&mode=&order=0&thold=0\">$title</a> * ";
} elseif ($n==2) {
$content .="NewsComment: <a href=\"modules.php?name=News&file=article&sid=$id&mode=&order=0&thold=0\">$title</a> * ";
} elseif ($n==3) {
$content .="Review: <a href=\"modules.php?name=MReviews&op=show&rid=$id\">$title</a> * ";
} elseif ($n==4) {
$content .="Download: <a href=\"modules.php?name=Downloads&d_op=viewdownloaddetails&lid=$id\">$title</a> * ";
} elseif ($n==5) {
$content .="Content: <a href=\"modules.php?name=Content&pa=showpage&pid=$id\">$title</a> * ";
} else {
$content .="";
}
}
|
It seems to work ok with me, but if anyone want to refine it, i'd be more than happy. |
|
|
|
 |
|