Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.
Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

Community



Donate

Donate for PortaMx !
Your donation is safe and helps support the issues and causes you care most about.

Stats

  • *Total Members: 4339
  • *Latest: AJ

  • *Total Posts: 15833
  • *Total Topics: 2396
  • *Online Today: 5
  • *Most Online: 157
(27.08.09, 03:54:53)
  • *Users: 0
  • *Guests: 3
  • *Total: 3

Author Topic: RSS Feed for PmxBlog  (Read 2818 times)

0 Members and 0 Guests are viewing this topic.

Offline Virtuaus Labs

  • Technical Director
  • Newbie
  • *
  • Posts: 3
  • Gender: Male
    • Virtuaus Labs
RSS Feed for PmxBlog
« on: 26.02.12, 20:43:40 »
Hi,

Since there was currently no RSS support for PmxBlog (that I am aware of) and we needed it for our site (we post RSS data to our twitter/facebook accounts) I made one. I am a developer, but not a PHP developer so I know the code is not yet robust, but it seems to get the job done. I want to contribute it to the community in the hopes that others may find it useful and contribute to it and make it better. Currently a lot of items are hard coded, but you can easily change them by updating the variables. Also I had to make a small change to PmxBlogSSI.php so that the PmxBlogSSI_Recent function also returned the article id. Updated PmxBlogSSI.php + blogrss.php are included in the attachment.

Code: [Select]
<?php 

// ----------------------------------------------------------
// -- BlogRSS.php  PMX Blog RSS                            --                                       
// ----------------------------------------------------------
// -- Version: 0.1 for PmxBlog 1.0                         --
// -- Copyright 2012  Virtuaus Media                       --
// -- Support and Updates at:                              --
// --   support@virtuaus.com                               --
// --   http://virtuaus.com                                --
// ----------------------------------------------------------
// 2/26/2012:
//  * Initial Release
// ----------------------------------------------------------

/*
  Put in the <head></head> section of your site to allow 
  browser to "see" this rss feed.
  
  <link rel="alternate" type="application/rss+xml" title="Virtuaus Media Blog RSS Feed (RSS 2.0)" href="http://virtuaus.com/blogrss.php" />
*/

// check of PmxBlog is enabled
if(defined('PMXBlog'))
   return;
  
// include PmxBlog SSI 
include_once('PmxBlogSSI.php');

// check if pmxblog is enabled
if(empty($modSettings['pmxblog_enabled']))
  return;

// RSS Feed variables
$blogposts      256;                                            // blog posts to show
$blogcontentlen 128;                                            // blog content length
$blogid         =  1;                                             // blog ID
$blogtitle      'Virtuaus Labs Blog';                           // blog title
$bloglink       'http://virtuaus.com/index.php?action=pmxblog'// blog link
$blogdesc       'Company Development Blog';                     // blog description

// define content length
$context['PmxBlog']['content_len'] = $blogcontentlen

// get blog post
$posts PmxBlogSSI_Recent($blogposts$blogid11'');

// set hmtl content header
header("Content-type: text/xml");

// output rss header
echo "<?xml version='1.0'?>

  <rss version='2.0'>
  <channel>
    <title>$blogtitle</title>
    <link>$blogtitle</link>
    <description>$blogdesc</description>
    <language>en-us</language>";

    // loop thru each post
    foreach($posts as $rcb)
    {
      // process pubdate
      if(!empty($rcb['unread_cmnt']) && !empty($cmntdate_onnews))
        $pubdate = date("D, d M Y H:i:s T", $rcb['cmnt_date']);
      else
        $pubdate = date("D, d M Y H:i:s T", $rcb['cont_date']);
     
      // get article id
      $artid   = $rcb['artid'];
     
      // get article data
      $article = PmxBlogSSI_GetArticle($artid, ''); // get article dataq
     
      // get article body
      $body    = Post_Teaser($article['body']);     // call the teaser
     
      // output blog item
      echo '<item>
        <title>'.$rcb['subject'].'</title>
        <link><![CDATA['.$rcb['conturl'].']]></link>
        <description><![CDATA['.$body.']]></description>
        <author>'.$article['ownername'].'</author>
        <category><![CDATA['.$article['catname'].']]></category>       
        <pubDate>'.$pubdate.'</pubDate>
        <guid><![CDATA['.$rcb['conturl'].']]></guid>
       </item>';
    }

  // finish rss feed data
  echo "</channel></rss>";
?>



Jarrod Davis
Technical Director @ Virtuaus Labs
FaceBook / Twitter / YouTube / RSS