Forum Activity

Forum feed

EZComments in Top List  Top

  • I was wondering, is it very difficult to add the "most comented stories" in Top List if you use EZComments?

    I haven't seen any implementation of it yet, but it is probably not that hard to accomplish...

    Anybody already has this?
  • The top list module is currently hard-coded to look at certain tables. So it would require adding a section of code to the module for EZComments. I've not done it and, at the moment, have no time to look at this code..... But it shouldn't be *that* difficult....

    -Mark

    --
    Visit My homepage and Zikula themes.
  • I see, in the modules/Top_List/index.php file I found:

    Code

    if (pnModAvailable('Comments')) {
            /**
             * Top 10 commented stories
             */

            $column = &$pntable['stories_column'];
            $myquery = "SELECT $column[sid], $column[title], $column[comments]
                                    FROM $pntable[stories] "
    .$queryalang."
                                    ORDER BY $column[comments] DESC"
    ;
            $result =& $dbconn->SelectLimit($myquery,$top);

            if (!$result->EOF) {
                    echo '<h2>'.$top.' '._COMMENTEDSTORIES.'</h2>'."\n";
                    $lugar=1;
                    while(list($sid, $title, $comments) = $result->fields) {
                            if($comments>0) {
                                    if (empty($title)) {
                                       $title = '- '._NOTITLE.' -';
                                    }
                                    echo "&nbsp;$lugar: <a href=\"index.php?name=News&amp;file=article&amp;sid=$sid\">" . pnVarPrepForDisplay(pnVarCensor($title)) . "</a> - (".pnVarPrepForDisplay($comments)." "._COMMENTS.")<br />\n";
                                    $lugar++;
                            }
                            $result->MoveNext();
                    }
                    echo '<br />'."\n";
            }
            $result->Close();
    }


    I guess it's just a matter to adjust for EZComments fields. Mmmm :D
  • This is my first try; of course, it does not work (Don't even try!) But I hope I can find the errors and fix it:

    Code

    if (pnModAvailable('EZComments')) {

             // Top 10 commented stories from EZComments

            $column = &$pntable['stories_column'];
            $column1 = &$pntable['ezcomments_column'];
            $total = 0;
            $myquery = "SELECT $column[sid], $column[title], count($column1[objectid]) AS $total
                                    FROM $pntable[stories] "
    .$queryalang."
                                    LEFT JOIN $pntable[ezcomments] ON $column[sid] = $column1[objectid]
                                    GROUP BY $column1[objectid]
                                    ORDER BY $total DESC"
    ;
            $result =& $dbconn->SelectLimit($myquery,$top);

            if (!$result->EOF) {
                    echo '<h2>'.$top.' '._COMMENTEDSTORIES.'</h2>'."\n";
                    $lugar=1;
                    while(list($sid, $title, $total) = $result->fields) {
                            if($total>0) {
                                    if (empty($title)) {
                                       $title = '- '._NOTITLE.' -';
                                    }
                                    echo "&nbsp;$lugar: <a href=\"index.php?name=News&amp;file=article&amp;sid=$sid\">" . pnVarPrepForDisplay(pnVarCensor($title)) . "</a> - (".pnVarPrepForDisplay($total)." "._COMMENTS.")<br />\n";
                                    $lugar++;
                            }
                            $result->MoveNext();
                    }
                    echo '<br />'."\n";
            }
            $result->Close();
    }


    If anybody has suggestions, they will be greatly appreciated, since my knowledge of PostNuke is really low :(
  • first thing evident reading your code is that you need to add:

    Code

    pnModDBInfoLoad('EZComments');

    But this line should be before calling pnDBGetTables(); or it will not works.
    Also in your SQL query you should test no only that that $column[sid] = $column1[objectid] but also that the ezcomment item is for the News module.
    maybe there are other problems, you will need some testing.

    --
    Visit my live reef aquarium.

    My Amazon wish list.

This list is based on the users active over the last 60 minutes.