Author Topic: Indivdual RSS Feeds for each category  (Read 6947 times)

0 Members and 1 Guest are viewing this topic.

Offline zoomos

  • Newbie
  • *
  • Posts: 14
    • View Profile
Indivdual RSS Feeds for each category
« on: May 23, 2006, 02:55:18 AM »
I was wondering if anybody has made a RSS feed for each category.

game.php for all game category
pictures.php for all pictures etc..

Code: [Select]
<?
/*************************************************
* RSS Feed for 4images *
* beta 0.1 *
* Email:
*/

//------------ CONFIG ----------------------------

$num_new_images = 50;
/*
u can uncomment this, if you want to use config variables from 4images config
$num_new_images = $config['image_cells'];
*/

//because we have no session here, we have to hardcode this values
define('SCRIPT_URL', 'sitename'); //no trailing slash
define('LANGUAGE', 'EN');

define('ROOT_PATH', '');

//----- END CONFIG--------------------------------------------

include(ROOT_PATH.'global.php');
$main_template = 'rsss';

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_thumb_file, i.image_media_file, i.image_keywords, i.image_date, i.image_active, c.cat_name, c.cat_description
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id
        ORDER BY i.image_date DESC
        LIMIT $num_new_images";


$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
$format="Y-m-d\TH:i:s+00:00"; //the time format for rss date
while($image_row = $site_db->fetch_array($result)){
if (!check_media_type($image_row['image_media_file']))
  {
    $file_src = ICON_PATH."/404.gif";
  }
  else
  {
    if (!get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0))
    {
      $file_src = ICON_PATH."/".get_file_extension($image_row['image_media_file']).".gif";
    }
    else
    {
      $file_src = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1);
    }
  }
  $image_info = @getimagesize($file_src);
  $width_height = (!empty($image_info[3])) ? " ".$image_info[3] : "";
  $file_src = SCRIPT_URL."/".str_replace(ROOT_PATH, "", $file_src);
  $thumb = "<a href=\"".SCRIPT_URL."/media".$image_row['image_id'].".html\"><img src=\"".$file_src."\" border=\"1\"".$width_height." alt=\"".$image_row['image_name']."\" /></a>";
$site_template->register_vars(array(
"title" => $image_row["image_name"],
"description" => $image_row["image_description"],
"category_domain" => SCRIPT_URL."/cat".$image_row["cat_id"].".html",
"category" => $image_row["cat_name"],
"cat_description" => $cat_cache[$cat_id]['cat_description'],
"link" => SCRIPT_URL."/media".$image_row["image_id"].".html",
"date" => format_date($format,$image_row["image_date"]),
"thumbnail" => $file_src,
));
$new_images.=$site_template->parse_template("rsssitem");
}

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(
array(
"ctitle" => $config['site_name'],
"clink" => SCRIPT_URL,
"cdescription" => $config['site_name']." RSS Feed",
"language" =>LANGUAGE,
"ititle" =>"",
"iurl" => SCRIPT_URL."/".TEMPLATE_PATH."/images/header_logo.gif",
"ilink" => SCRIPT_URL,
"items" => $new_images,
)
);
header("Content-type: text/xml");
$site_template->print_template('<?xml version="1.0" encoding="ISO-8859-1"?>'.$site_template->parse_template($main_template));
?>

Can someone show me what to edit to just display a specific category and the rest I can figure out.  (the RSSS <-- was so I could edit without screwing up the working feed.)

aim: zoomos

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Indivdual RSS Feeds for each category
« Reply #1 on: May 23, 2006, 03:38:26 AM »
why so complicated?
replace
Code: [Select]
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id
with:
Code: [Select]
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id".($cat_id ? " AND i.cat_id = ".$cat_id : "")."
Then simply add cat_id=<category id> in the url. i.e. http://example/rss.php?cat_id=12

P.S. Please read forum rules and next time please reply to the appropriate topic.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline zoomos

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Indivdual RSS Feeds for each category
« Reply #2 on: May 23, 2006, 04:23:36 AM »
Sorry.. It said Request.


Thanks nino.

If someone has the rewrite installed.

RewriteRule ^games\.html$ rss.php?cat_id=3
that way you don't have the query string.

I'm learning php and sql but not good enough to know exactly what to edit.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Indivdual RSS Feeds for each category
« Reply #3 on: May 23, 2006, 05:10:10 AM »
Sorry.. It said Request.
Requests for 4images addons, and not addons for already published addons ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)