CMSimple_XH RSS addon

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
jze
Posts: 10
Joined: Thu Jul 15, 2010 1:21 pm
Location: Kiel
Contact:

CMSimple_XH RSS addon

Post by jze » Wed Jul 28, 2010 7:55 am

I have written a PHP script (a plain PHP script that goes into CMSimple's base directory, not a plugin) that provides the last edits to my website as RSS feed. My website is edited by several persons and I use the RSS feed to keed myself updated what's going on at the website.

One major problem: The links to h2 und h3 pages do not work. Since all information is read from pagedata.php the complete path to the sub-page is not known.

It would also be nice if the current content of modified pages could be included into the RSS feed.

For my purposes the current functionality is enough. Maybe someone else finds this useful, too.

Here is the code for rss.php:

Code: Select all

<?php 
include('./content/pagedata.php');
include('./cmsimple/config.php');

$language = $cf['meta']['content-language'];
include("./cmsimple/languages/$language.php");

$sorted_pages = msort($page_data, 'last_edit',false);
$max = 20;
if( count($page_data) < $max )
    $max = count($page_data);

$urlBase = 'http://'.parse_url('http://'.$_SERVER['HTTP_HOST'], PHP_URL_HOST).str_replace('rss.php','',parse_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], PHP_URL_PATH));

header( "Content-type: text/xml; charset=UTF-8" );

echo '<rss version="2.0" >';
echo '<channel>';
echo '<title>'.$tx['site']['title'].'</title>';
echo "<link>$urlBase</link>";
echo '<description>'.$tx['meta']['description'].'</description>';
echo "<language>$language</language>";

for( $i=0; $i<$max; $i++) {
    $title = str_replace('_',' ',html_entity_decode(urldecode($sorted_pages[$i]['url']),ENT_NOQUOTES,'UTF-8'));
    echo '<item>';
    echo "<title>$title</title>";
    echo "<link>$urlBase?".$sorted_pages[$i]['url'].'</link>';
    echo '<pubDate>'.date('r',$sorted_pages[$i]['last_edit']).'</pubDate>';
    echo '</item>';
}

echo '</channel>';
echo '</rss>';


function msort($array, $id="id", $sort_ascending=true) {
  $temp_array = array();
  while(count($array)>0) {
    $lowest_id = 0;
    $index=0;
    foreach ($array as $item) {
      if (isset($item[$id])) {
        if ($array[$lowest_id][$id]) {
          if ($item[$id]<$array[$lowest_id][$id]) {
            $lowest_id = $index;
          }
        }
      }
      $index++;
    }
    $temp_array[] = $array[$lowest_id];
    $array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1));
  }
  if ($sort_ascending) {
    return $temp_array;
  } else {
    return array_reverse($temp_array);
  }
}
?>

Termin
Posts: 101
Joined: Thu Jan 27, 2011 8:55 am
Contact:

Re: CMSimple_XH RSS addon

Post by Termin » Wed Mar 09, 2011 5:00 pm

Not working! :cry:
ERORR
Not Found
The requested URL /<rss version= was not found on this server.

Post Reply