Only registered users can see links on this board! Get registered or login to the forums!
- 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?
Joined: Aug 27, 2002 Posts: 17057 Location: Kansas
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
...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?
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.
Joined: Aug 27, 2002 Posts: 17057 Location: Kansas
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
Only registered users can see links on this board! Get registered or login to the forums!
. 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
...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.
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum