Geeklog France
 

Block recent comments

function phpblock_recentcomments() {
    global $_CONF, $_TABLES, $LANG01;
 
    $recentcomments = '<div id="recentcomments">';
 
    // Set the number of comments to show
        $limits = 5;
 
        $sql = "SELECT DISTINCT COUNT(*) AS dups, type, st.title as title, c.comment as comment, c.cid as cid, c.uid as uid, st.sid as sid, max(c.date) AS lastdate "
        . "FROM  c,  st "
        . "WHERE st.sid = c.sid AND st.draft_flag = 0 AND st.commentcode >= 0 "
        . COM_getPermSQL('AND', 0, 2,'st')  // notice we can use st here.
        . $topicsql
        . COM_getLangSQL('sid', 'AND','st')
        . "GROUP BY c.sid,type, c.comment, st.title, st.sid, c.cid, c.uid "
        . "ORDER BY 5 DESC LIMIT " . $limits;
 
        $result = DB_query( $sql );
 
        $nrows = DB_numRows( $result );
 
        if( $nrows > 0 )
        {
            $newcomments = array();
 
            for( $x = 0; $x < $nrows; $x++ )
            {
                $A = DB_fetchArray( $result );
 
                if(( $A['type'] == 'article' ) || empty( $A['type'] ))
                {
                    $url = COM_buildUrl( $_CONF['site_url']
                        . '/article.php?story=' . $A['sid'] ) . '#comments';
                }
 
                $username = COM_getDisplayName( $A['uid'] );
                $lastcomment = $A['comment'];
                $title = COM_undoSpecialChars( stripslashes( strip_tags( $lastcomment )));
                $titletouse = COM_truncate( $title, 80, '...' );
                $acomment = str_replace( '$', '&#36;', $titletouse );
                $newcomments[] = '<strong>' . $username .'</strong> ' . COM_createLink($acomment, $url);
            }
 
            $recentcomments .= COM_makeList( $newcomments, 'recentcomments' );
        }
        else
        {
            $recentcomments .= $LANG01[86] . '<br' . XHTML . '>' . LB;
        }
    $recentcomments .='</div>';
 
    return $recentcomments;
Connecté en tant que : Guest (Guest)
blocks/recentcomments.txt · Dernière modification: 2009/01/16 14:30 par ::Ben
 

Download geeklog

Last version 1.8.1

Espace Membre





Devenir membre
Enregistrez-vous

Mot de passe oublié ?

Change language

Categories

  • Geeklog (38)
  • Plugins (53)
  • Thèmes (17)
  • My cart

    Votre panier (0 article)

    Votre panier est vide!

    0.00 EUR

    Visual Theme Switcher

    Test out available themes by selecting from one of the 6 available themes or give the Visual Switcher a try:

    Follow us on twitter

    En ligne

    Visiteurs: 10