Fork me on GitHub
Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
New Posts New Topics All Posts All Forums Index General Modules Themes Development International XOOPS.org

Search

Nominate XOOPS!

Learn XOOPS Core

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $15.00
Net Balance: $14.11
Left to go: $85.89

Donations
Anonymous ($15)Jul-20

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

- 2 2.5 2.6 3.0 4 6 adslight Android AntiHarvesting AntiMalUser AntiSpam API Apple Battlefield billige Blocks Bootstrap Captcha cell chronolabs content CĂN demo docek download Dresses evden eve facebook Fat floor Food for free Gateway Google Guide herre Home Honeypot HP html5 Human HỘ IP iPhone jQuery Language List log Loss module modules Monster new newbb news NHÀ online PARK Payment phone PHP Prevention profile project Protector publisher Rapid RESIDENCE responsive review Rights rmcommon Room security Sentry site Smartphone Smarty Spam stem Studio support tag tdmcreate template The Theme themes User userlog weight xoops Xortify XPayment ZendFramework

New Users

Registering user

# 137636

mzmaker05

Welcome to XOOPS!




Bottom   Previous Topic   Next Topic  Register To Post



#1 Posted on: 2011/4/9 15:04 #Comments #RSS #Feed for XOOPS
Put the following code in a file called something like comments.php in your XOOPS_ROOT_PATH where backend.php is featured and it will add a feed to your site for comments to import into twitter etc.

<?php
/**
 * XOOPS feed creator
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @since           2.0.0
 * @version         $Id: backend.php 4941 2010-07-22 17:13:36Z beckmi $
 */
 
include dirname(__FILE__) . DIRECTORY_SEPARATOR 'mainfile.php';

$GLOBALS['xoopsLogger']->activated false;
if (
function_exists('mb_http_output')) {
    
mb_http_output('pass');
}
header('Content-Type:text/xml; charset=utf-8');

include_once 
$GLOBALS['xoops']->path('class/template.php');
$tpl = new XoopsTpl();
$tpl->xoops_setCaching(2);
$tpl->xoops_setCacheTime(3600);
if (!
$tpl->is_cached('db:system_rss.html')) {
    
xoops_load('XoopsLocal');
    
$tpl->assign('channel_title'XoopsLocal::convert_encoding(htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
    
$tpl->assign('channel_link'XOOPS_URL '/');
    
$tpl->assign('channel_desc'XoopsLocal::convert_encoding(htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)));
    
$tpl->assign('channel_lastbuild'formatTimestamp(time(), 'rss'));
    
$tpl->assign('channel_webmaster'checkEmail($xoopsConfig['adminmail'], true));
    
$tpl->assign('channel_editor'checkEmail($xoopsConfig['adminmail'], true));
    
$tpl->assign('channel_category''News');
    
$tpl->assign('channel_generator''XOOPS');
    
$tpl->assign('channel_language'_LANGCODE);
    
$tpl->assign('image_url'XOOPS_URL '/images/logo.png');
    
$dimention getimagesize(XOOPS_ROOT_PATH '/images/logo.png');
    if (empty(
$dimention[0])) {
        
$width 88;
    } else {
        
$width = ($dimention[0] > 144) ? 144 $dimention[0];
    }
    if (empty(
$dimention[1])) {
        
$height 31;
    } else {
        
$height = ($dimention[1] > 400) ? 400 $dimention[1];
    }
    
$tpl->assign('image_width'$width);
    
$tpl->assign('image_height'$height);
    
    
$comments_handler xoops_gethandler('comment');
    
$criteria = new CriteriaCompo(new Criteria('com_status'2));
    if (isset(
$_REQUEST['modid'])&&is_numeric($_REQUEST['modid']))
        
$criteria->add(new Criteria('`com_modid`'intval($_REQUEST['modid'])));
    if (isset(
$_REQUEST['uid'])&&is_numeric($_REQUEST['uid']))
        
$criteria->add(new Criteria('`com_uid`'intval($_REQUEST['uid'])));
    
$criteria->setLimit(((isset($_REQUEST['num'])&&is_numeric($_REQUEST['num'])&&intval($_REQUEST['num'])>0)?intval($_REQUEST['num']):10));
    
$criteria->setSort('`com_created`');
    
$criteria->setOrder('DESC');
    
    
$module_handler xoops_gethandler('module');
    
$comments $comments_handler->getObjects($criteria);
    if (!empty(
$comments) && is_array($comments)) {
        
$myts =& MyTextSanitizer::getInstance();
        foreach (
$comments as $comment) {
            
$xoModule $module_handler->get($comment->getVar('com_modid'));
            
$comment_config $xoModule->getInfo('comments'); 
            
$tpl->append('items', array(
                
'title' => XoopsLocal::convert_encoding(htmlspecialchars($comment->getVar('com_title'), ENT_QUOTES)) ,
                
'link' => htmlspecialchars(XOOPS_URL '/modules/'.$xoModule->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode='.$GLOBALS['xoopsConfig']['com_mode'].'&com_order=0'.(strlen($comment->getVar('com_exparams'))>0?'&'.$comment->getVar('com_exparams'):'').'#comment'.$comment->getVar('com_id')),
                
'guid' => htmlspecialchars(XOOPS_URL '/modules/'.$xoModule->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode='.$GLOBALS['xoopsConfig']['com_mode'].'&com_order=0'.(strlen($comment->getVar('com_exparams'))>0?'&'.$comment->getVar('com_exparams'):'').'#comment'.$comment->getVar('com_id')),
                
'category' => XoopsLocal::convert_encoding(htmlspecialchars($xoModule->getVar('name'))) ,
                
'pubdate' => formatTimestamp($comment->getVar('com_created'), 'rss') ,
                
'description' => XoopsLocal::convert_encoding(htmlspecialchars($myts->displayTarea($comment->getVar('com_text'), $comment->getVar('dohtml'), $comment->getVar('dosmiley'), $comment->getVar('doxcode'), $comment->getVar('doimage'), $comment->getVar('dobr')), ENT_QUOTES))));
        }
    }
}
$tpl->display('db:system_rss.html');
?>

* Code Final Edited 10/04/2011 6:25:20 AEST

Top


Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

* www.twitter.com/NegativityGear
* www.sourceforge.net/projects/chronolabs/
* www.facebook.com/epsacey
wishcraft
Module Developer
Module Developer
Joined:
2007/5/18 15:56
From Dulwich Hill, Sydney, Australia
Group:
Registered Users
Posts: 2119
(Show More) (Show Less)


#2 Posted on: 2011/4/9 15:44 Re: #Comments #RSS #Feed for XOOPS
By including the following function, you can customise the code for sending a twitter explicit RSS Feed Title so the words longer than xxx are and have a hash placed in front of them for twitters RSS Aggregation

function xoopsTweetString($title$doit=false$wordlen=4) {
    if (
$doit==true) {
        
$title_array explode(' '$title);
        
$title '';
        foreach(
$title_array as $item) {
            if (
strlen($item)>$wordlen
                
$title .= ' #'.$item;
            else 
                
$title .= ' '.$item;
        }
    }
    return 
trim($title);
}


The RSS Code with this included would look like:

<?php
/**
 * XOOPS feed creator
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @since           2.0.0
 * @version         $Id: backend.php 4941 2010-07-22 17:13:36Z beckmi $
 */
if (!function_exists('xoopsTweetString')) {
    function 
xoopsTweetString($title$doit=false$wordlen=4) {
        if (
$doit==true) {
            
$title_array explode(' '$title);
            
$title '';
            foreach(
$title_array as $item) {
                if (
strlen($item)>$wordlen
                    
$title .= ' #'.$item;
                else 
                    
$title .= ' '.$item;
            }
        }
        return 
trim($title);
    }
}

include 
dirname(__FILE__) . DIRECTORY_SEPARATOR 'mainfile.php';

$GLOBALS['xoopsLogger']->activated false;
if (
function_exists('mb_http_output')) {
    
mb_http_output('pass');
}
header('Content-Type:text/xml; charset=utf-8');

include_once 
$GLOBALS['xoops']->path('class/template.php');
$tpl = new XoopsTpl();
$tpl->xoops_setCaching(2);
$tpl->xoops_setCacheTime(3600);
if (!
$tpl->is_cached('db:system_rss.html')) {
    
xoops_load('XoopsLocal');
    
$tpl->assign('channel_title'XoopsLocal::convert_encoding(htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
    
$tpl->assign('channel_link'XOOPS_URL '/');
    
$tpl->assign('channel_desc'XoopsLocal::convert_encoding(htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)));
    
$tpl->assign('channel_lastbuild'formatTimestamp(time(), 'rss'));
    
$tpl->assign('channel_webmaster'checkEmail($xoopsConfig['adminmail'], true));
    
$tpl->assign('channel_editor'checkEmail($xoopsConfig['adminmail'], true));
    
$tpl->assign('channel_category''News');
    
$tpl->assign('channel_generator''XOOPS');
    
$tpl->assign('channel_language'_LANGCODE);
    
$tpl->assign('image_url'XOOPS_URL '/images/logo.png');
    
$dimention getimagesize(XOOPS_ROOT_PATH '/images/logo.png');
    if (empty(
$dimention[0])) {
        
$width 88;
    } else {
        
$width = ($dimention[0] > 144) ? 144 $dimention[0];
    }
    if (empty(
$dimention[1])) {
        
$height 31;
    } else {
        
$height = ($dimention[1] > 400) ? 400 $dimention[1];
    }
    
$tpl->assign('image_width'$width);
    
$tpl->assign('image_height'$height);
    
    
$comments_handler xoops_gethandler('comment');
    
$criteria = new CriteriaCompo(new Criteria('com_status'2));
    if (isset(
$_REQUEST['modid'])&&is_numeric($_REQUEST['modid']))
        
$criteria->add(new Criteria('`com_modid`'intval($_REQUEST['modid'])));
    if (isset(
$_REQUEST['uid'])&&is_numeric($_REQUEST['uid']))
        
$criteria->add(new Criteria('`com_uid`'intval($_REQUEST['uid'])));
    
$criteria->setLimit(((isset($_REQUEST['num'])&&is_numeric($_REQUEST['num'])&&intval($_REQUEST['num'])>0)?intval($_REQUEST['num']):10));
    
$criteria->setSort('`com_created`');
    
$criteria->setOrder('DESC');
    
    
$module_handler xoops_gethandler('module');
    
$comments $comments_handler->getObjects($criteria);
    if (!empty(
$comments) && is_array($comments)) {
        
$myts =& MyTextSanitizer::getInstance();
        foreach (
$comments as $comment) {
            
$xoModule $module_handler->get($comment->getVar('com_modid'));
            
$comment_config $xoModule->getInfo('comments'); 
            
$tpl->append('items', array(
                
'title' => XoopsLocal::convert_encoding(htmlspecialchars(xoopsTweetString($comment->getVar('com_title'), isset($_REQUEST['tweet']), ((isset($_REQUEST['tweetlen'])&&is_numeric($_REQUEST['tweetlen'])&&intval($_REQUEST['tweetlen'])>0)?intval($_REQUEST['tweetlen']):4)), ENT_QUOTES)) ,
                
'link' => htmlspecialchars(XOOPS_URL '/modules/'.$xoModule->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode='.$GLOBALS['xoopsConfig']['com_mode'].'&com_order=0'.(strlen($comment->getVar('com_exparams'))>0?'&'.$comment->getVar('com_exparams'):'').'#comment'.$comment->getVar('com_id')),
                
'guid' => htmlspecialchars(XOOPS_URL '/modules/'.$xoModule->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode='.$GLOBALS['xoopsConfig']['com_mode'].'&com_order=0'.(strlen($comment->getVar('com_exparams'))>0?'&'.$comment->getVar('com_exparams'):'').'#comment'.$comment->getVar('com_id')),
                
'category' => XoopsLocal::convert_encoding(htmlspecialchars($xoModule->getVar('name'))) ,
                
'pubdate' => formatTimestamp($comment->getVar('com_created'), 'rss') ,
                
'description' => XoopsLocal::convert_encoding(htmlspecialchars($myts->displayTarea($comment->getVar('com_text'), $comment->getVar('dohtml'), $comment->getVar('dosmiley'), $comment->getVar('doxcode'), $comment->getVar('doimage'), $comment->getVar('dobr')), ENT_QUOTES))));
        }
    }
}
$tpl->display('db:system_rss.html');
?>


To Turn this on you would do http://yoursite.com/comments.php?tweet=1

Top


Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

* www.twitter.com/NegativityGear
* www.sourceforge.net/projects/chronolabs/
* www.facebook.com/epsacey
wishcraft
Module Developer
Module Developer
Joined:
2007/5/18 15:56
From Dulwich Hill, Sydney, Australia
Group:
Registered Users
Posts: 2119
(Show More) (Show Less)


#3 Posted on: 2011/4/12 12:51 Re: #Comments #RSS #Feed for XOOPS
Paul from Stop forum spam was amused by this it is a comments rss feed @ xortify http://xortify.chronolabs.coop/comments.php?tweet=1 in tweet mode

Top


Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

* www.twitter.com/NegativityGear
* www.sourceforge.net/projects/chronolabs/
* www.facebook.com/epsacey
wishcraft
Module Developer
Module Developer
Joined:
2007/5/18 15:56
From Dulwich Hill, Sydney, Australia
Group:
Registered Users
Posts: 2119
(Show More) (Show Less)


#4 Posted on: 2011/4/13 3:38 Re: #Comments #RSS #Feed for XOOPS
thanks simon

a suggestion ... would be a better name backcoms.php?

Top


Blog| Modules, Themes, Tutorials|[url=http://mobile.txmodxoops.org]
timgno
Module Developer
Module Developer
Joined:
2007/6/21 13:54
From Italy
Group:
Registered Users
Posts: 1234
(Show More) (Show Less)







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You can vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.

[Advanced Search]