PHP Web Host - Quality Web Hosting For All PHP Applications Clan Themes! We make clans look good!!
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
pellow
New Member
New Member


Joined: Aug 16, 2005
Posts: 3

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

Hi
I have a phpnuke-website in Denmark -
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?

poul erik
View user's profile Send private message Send e-mail
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16647
Location: Kansas

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

So you want to just feed the content titles?
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
pellow
New Member
New Member


Joined: Aug 16, 2005
Posts: 3

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

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

regards

pel
View user's profile Send private message Send e-mail
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16647
Location: Kansas

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

Sure. Let me whip something up and I'll post back.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16647
Location: Kansas

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

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;
?>
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
pellow
New Member
New Member


Joined: Aug 16, 2005
Posts: 3

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

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
View user's profile Send private message Send e-mail
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16647
Location: Kansas

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

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;
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
NoFantasy
Worker
Worker


Joined: Apr 26, 2005
Posts: 114

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

...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
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16647
Location: Kansas

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

Of course.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
NoFantasy
Worker
Worker


Joined: Apr 26, 2005
Posts: 114

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

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.
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16647
Location: Kansas

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

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 Smile
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
NoFantasy
Worker
Worker


Joined: Apr 26, 2005
Posts: 114

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

Ty Sir, at least now i have a clue where to start, what to look for and what to not look for.
View user's profile Send private message
NoFantasy
Worker
Worker


Joined: Apr 26, 2005
Posts: 114

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

...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.
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2010 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum