Author Topic: new MOD for 4images users ... RSS NEWS FEED & feed reader  (Read 14660 times)

0 Members and 1 Guest are viewing this topic.

Offline aq8.net

  • Pre-Newbie
  • Posts: 7
    • View Profile
new MOD for 4images users ... RSS NEWS FEED & feed reader
« on: December 25, 2005, 02:16:12 PM »
 :wink:

hi
(NOTE : ONLY FOR those who make another simple news MOD)  http://www.4homepages.de/forum/index.php?topic=9064.0
i do make a poor mod for 4images users so they can make rss feed for ther news section

NO need to change any files

1st file is newsrssfeed.php which change the cod from php to rss lang

2nd file is read-rss-library-news.php to change the rss into html or php lang again

the 3rd file is the templates file rss.html

now
newsrssfeed.php

<?
/*************************************************
 * RSS Feed for 4images                          *
 * beta 0.1                                      *
 * Email:
 */

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

$num_new_images = 10;

//because we have no session here, we have to hardcode this values
define('SCRIPT_URL', 'http://www.your-website.com/4images'); //no trailing slash
define('LANGUAGE', 'english');

define('ROOT_PATH', './');

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

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



$sql = "SELECT news_id, news_title, news_text, user_name, news_date
        FROM ".NEWS_TABLE."
        ORDER BY news_id 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($news_row = $site_db->fetch_array($result)){
  $site_template->register_vars(array(
                  "title" => $news_row["news_title"],             
                  "description" => $news_row["news_text"],
                  "link" => SCRIPT_URL."/newsfull.php?news_id=".$news_row["news_id"],
                  "id" => SCRIPT_URL."/newsfull.php?news_id=".$news_row["news_id"],
                  "date" => format_date($format,$news_row["news_date"]),
                  ));
  $new_images.=$site_template->parse_template("rssitem");
 }

//-----------------------------------------------------
//--- 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($site_template->parse_template($main_template));
?>


now the read-rss-library-news.php

<?php
// Basic Requirements
$backend = "http://www.your-website.com/4images/newsrssfeed.php";
// End

// variables needed later
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
// end

function startElement($parser, $tagName, $attrs) {

  // The function used when an element is encountered

  global $insideitem, $tag;

  if ($insideitem) {

    $tag = $tagName;

  } elseif ($tagName == "ITEM") {

    $insideitem = true;
  }

}

function characterData($parser, $data) {

  // The function used to parse all other data than tags

  global $insideitem, $tag, $title, $description, $link;
 
  if ($insideitem) {
 
    switch ($tag) {
    case "TITLE":
      $title .= $data;
      break;
    case "DESCRIPTION":
      $description .= $data;
      break;
    case "LINK":
$link .= $data;

$aboreem = str_replace ($nums, $images, $link);

$link = $aboreem;
      break;
    }

  }

}

function endElement($parser, $tagName) {

  // This function is used when an end-tag is encountered.

  global $insideitem, $tag, $title, $description, $image, $link;
 
  if ($tagName == "ITEM") {
 
  printf("<p><b><a href='%s'><li>%s</li></a></b></p>", // make our title into an actual link
       trim($link),htmlspecialchars(trim($title))); // remove html characters from the title
    printf("<p><b>%s</b></p>",$description); // Print out the live journal entry
   $title = $description = $link = $insideitem = false;

  }

}

// Now to the parsing itself. Starts by creating it:

$xml_parser = xml_parser_create();

// Then setup the handlers:

xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

// Open the actual datafile:

$fp = fopen($backend, r);

// Run through it line by line and parse:

while ($data = fread($fp, 4096)) {
  xml_parse($xml_parser, $data, feof($fp))
    or die(sprintf("XML error: %s at line %d",
           xml_error_string(xml_get_error_code($xml_parser)),
           xml_get_current_line_number($xml_parser)));
}

// Close the datafile

fclose($fp);

// Free any memmory used

xml_parser_free($xml_parser);

?>


and for the rss.html

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>{ctitle}</title>
    <link>{clink}</link>
    <description>{cdescription}</description>
    <language>{language}</language>
    <image>
      <title>{ititle}</title>
      <url>{iurl}</url>
      <link>{ilink}</link>
    </image>
    {items}
  </channel>
</rss>


thats all

sorry for my poor english

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: new MOD for 4images users ... RSS NEWS FEED & feed reader
« Reply #1 on: December 25, 2005, 02:32:58 PM »
... why you didn't use the search ... ?
... we have for NEWS-RSS-FEED already a MOD ...
... http://www.4homepages.de/forum/index.php?topic=10715.0
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline aq8.net

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: new MOD for 4images users ... RSS NEWS FEED & feed reader
« Reply #2 on: December 25, 2005, 02:47:17 PM »
becouse its for the news section (the MOD) not for the images name

please this is 1st time mode ever i am sure

the link you add is for the photos news

the mode i add is for the news ONLY (no images)

OK ?

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: new MOD for 4images users ... RSS NEWS FEED & feed reader
« Reply #3 on: December 25, 2005, 03:03:12 PM »
please read carefully !

[MOD] News-RSS-Feed V.1.0

Quote
  • This RSS-Feed presented 4images-Website-News.
  • In the MOD-Forum exist already a MOD for a RSS-Feed, but this feed shows the newest images from your website.
  • This News-RSS-Feed shows in a News-Reeder the most current news of your 4images website (not newest images...!).

mawenzi

Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline aq8.net

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: new MOD for 4images users ... RSS NEWS FEED & feed reader
« Reply #4 on: December 25, 2005, 05:36:35 PM »
i am so sorry :(