Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
pellow
New Member
New Member



Joined: Aug 16, 2005
Posts: 3

PostPosted: Tue Aug 16, 2005 3:16 pm Reply with quote

Hi
I have a phpnuke-website in Denmark - www.rossem.dk - 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
 
View user's profile Send private message Send e-mail
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Wed Aug 17, 2005 7:52 am Reply with quote

So you want to just feed the content titles?
 
View user's profile Send private message
pellow







PostPosted: Wed Aug 17, 2005 7:59 am Reply with quote

Yes - thats all I need. Do you think you can help me?

regards

pel
 
Raven







PostPosted: Wed Aug 17, 2005 8:00 am Reply with quote

Sure. Let me whip something up and I'll post back.
 
Raven







PostPosted: Wed Aug 17, 2005 11:25 pm Reply with quote

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&amp;pa=showpage&amp;pid='.intval($row['pid']).'</link>'.$slf
              . '</item>'.$dlf
              ;
}

$rssFeed .= '</channel>'.$slf
          . '</rss>'
          ;
echo $rssFeed;
?>
 
pellow







PostPosted: Thu Aug 18, 2005 12:34 am Reply with quote

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







PostPosted: Thu Aug 18, 2005 1:16 am Reply with quote

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&amp;pa=showpage&amp;pid='.intval($row['pid']).'</link>'.$slf
              . '<description>'.$text.'</description>'.$slf
              . '</item>'.$dlf
              ;
}
Before $rssFeed .= '</channel>'.$slf
. '</rss>'
;
echo $rssFeed;
 
NoFantasy
Worker
Worker



Joined: Apr 26, 2005
Posts: 114

PostPosted: Fri Jul 28, 2006 9:23 am Reply with quote

...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?
 
View user's profile Send private message
Raven







PostPosted: Fri Jul 28, 2006 9:37 am Reply with quote

Of course.
 
NoFantasy







PostPosted: Fri Jul 28, 2006 10:04 am Reply with quote

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







PostPosted: Fri Jul 28, 2006 10:18 am Reply with quote

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! ] . 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 Smile
 
NoFantasy







PostPosted: Fri Jul 28, 2006 10:23 am Reply with quote

Ty Sir, at least now i have a clue where to start, what to look for and what to not look for.
 
NoFantasy







PostPosted: Sun Aug 06, 2006 10:17 am Reply with quote

...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>&nbsp;&nbsp;";
   $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:&nbsp;<a href=\"modules.php?name=News&amp;file=article&amp;sid=$id&amp;mode=&amp;order=0&amp;thold=0\">$title</a>&nbsp;*&nbsp;";
      } elseif ($n==2) {
         $content .="NewsComment:&nbsp;<a href=\"modules.php?name=News&amp;file=article&amp;sid=$id&amp;mode=&amp;order=0&amp;thold=0\">$title</a>&nbsp;*&nbsp;";
      } elseif ($n==3) {
         $content .="Review:&nbsp;<a href=\"modules.php?name=MReviews&amp;op=show&amp;rid=$id\">$title</a>&nbsp;*&nbsp;";
      } elseif ($n==4) {
         $content .="Download:&nbsp;<a href=\"modules.php?name=Downloads&amp;d_op=viewdownloaddetails&amp;lid=$id\">$title</a>&nbsp;*&nbsp;";
      } elseif ($n==5) {
         $content .="Content:&nbsp;<a href=\"modules.php?name=Content&amp;pa=showpage&amp;pid=$id\">$title</a>&nbsp;*&nbsp;";
      } else {
         $content .="";
      }
}


It seems to work ok with me, but if anyone want to refine it, i'd be more than happy.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©