Fork me on GitHub

Rapport de message :*
 

Modification block Last commented item de MyComments

Titre du sujet : Modification block Last commented item de MyComments
par moss sur 26/01/2013 14:49:04

Bonjour tout le monde,

J'utilise le module MyComments et notamment son super block dernier sujet commenté... je souhaiterais juste récupérer une info supplémentaire à afficher dans le block...

Je voudrais récupérer le nombre de commentaires par item afin de visualiser la popularité d'un sujet...

Quelqu'un aurait une idée de comment faire ?

J'insere le code du block tel qu'il est si ça peut faciliter quelq'un à m'aider, merci d'avance

function b_mycomments2_show($options)
{
    global 
$xoopsUser;
    include_once 
XOOPS_ROOT_PATH.'/modules/mycomments/include/comment_constants.php';
    
$limit 10// If you  are not getting suficient results, please increase a little more this number
    
$block $comment_config $trackedItems = array();

    
$comment_handler =& xoops_getmodulehandler('comment','mycomments');
    
$moduleperm_handler =& xoops_gethandler('groupperm');
    
$member_handler =& xoops_gethandler('member');
    
$module_handler =& xoops_gethandler('module');

    
$criteria = new CriteriaCompo(new Criteria('com_status'MYCOM_ACTIVE));
    
$criteria->setLimit(intval($options[0] * $limit));
    
$criteria->setSort('com_created');
    
$criteria->setOrder('DESC');

    
$comments $comment_handler->getObjects($criteriatrue);
    
$modules $module_handler->getObjects(new Criteria('hascomments'1), true);

    
$count 0;
    foreach (
array_keys($comments) as $i) {
        if ( 
$count == $options[0])  continue;
        
$mid $comments[$i]->getVar('com_modid');

        if (
$xoopsUser) {
            if (!
$moduleperm_handler->checkRight('module_read'$mid$xoopsUser->getGroups())) {
                continue;
            }
        } else {
            if (!
$moduleperm_handler->checkRight('module_read'$midXOOPS_GROUP_ANONYMOUS)) {
                continue;
            }
        }

          
$com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.'<img src="'.XOOPS_URL '/modules/' $modules[$mid]->getVar('dirname''n') . '/images/ico.gif" />'.'</a>';
        if (!isset(
$comment_config[$mid])) {
            
$comment_config[$mid] = $modules[$mid]->getInfo('comments');
        }
        
$com['id'] = $i;
        
$com['title'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&com_id='.$i.'&com_rootid='.$comments[$i]->getVar('com_rootid').'&'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>';
        
$com['icon'] = htmlspecialchars$comments[$i]->getVar('com_icon'), ENT_QUOTES );
        
$com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
        
$com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'s');
        if (
$comments[$i]->getVar('com_uid') > 0) {
            
$poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
            if (
is_object($poster)) {
                
$com['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>';
            } else {
                
$com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
            }
        } else {
            
$com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
        }
        if (
count($trackedItems) > 0) {
            
$itemMatch false;
            foreach (
array_keys($trackedItems) as $j) {
                if (
$comments[$i]->getVar('com_modid') == $trackedItems[$j]['modid'] && $comments[$i]->getVar('com_itemid') == $trackedItems[$j]['itemid']) {
                    
$itemMatch true;
                }
            }
            if (!
$itemMatch) {
                
$block['comments'][] =& $com;
                
$trackedItems[] = array('modid' => $comments[$i]->getVar('com_modid'), 'itemid' => $comments[$i]->getVar('com_itemid') );
                
$count++;
            }
        } else {
            
$block['comments'][] =& $com;
            
$trackedItems[] = array('modid' => $comments[$i]->getVar('com_modid'), 'itemid' => $comments[$i]->getVar('com_itemid') );
            
$count++;
        }
        unset(
$com);
    }
    return 
$block;
}

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

74 Personne(s) en ligne (57 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 74 | Plus ...