To use this website completely, it is necessary to store cookies on your computer.
 

* Navigator

Expand - Collapse

* Statistic


  • *Total Posts: 16430
  • *Total Topics: 2522
  • *Online Today: 5
  • *Most Online: 292
(12. Nov 2016, 09:37:31)
  • *Users: 0
  • *Guests: 0
  • *Spiders: 1
  • *Total: 1

  • *Google

* Calendar

Mo
Tu
We
Th
Fr
Sa
Su
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

RSS Feed for PmxBlog

Started by Virtuaus Labs, 26. Feb 2012, 20:43:40

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

Virtuaus Labs

26. Feb 2012, 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>";
?>






[attachment deleted by admin]
Jarrod Davis
Technical Director @ Virtuaus Labs
FaceBook / Twitter / YouTube / RSS