Zikula: A Flexible Open Source Content Management System
home | forum | international support | contact us

Support Forum

Start ::  Extensions and Distributions Support ::  Modules ::  EZComments in Top List

Moderated by: Support Team

Bottom
EZComments in Top List

  • Link to this postingPosted: 18.10.2005, 21:47
    Profile Homepage
    Imoq
    rank:
    Helper Helper
    registered:
     September 2004
    Status:
    offline
    last visit:
    30.06.08
    Posts:
    110
    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?
  • Link to this postingPosted: 18.10.2005, 22:07
    Profile Homepage
    markwest
    rank:
    Moderator Moderator
    registered:
     March 2002
    Status:
    offline
    last visit:
    26.08.08
    Posts:
    7720
    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
  • Link to this postingPosted: 18.10.2005, 22:50
    Profile Homepage
    Imoq
    rank:
    Helper Helper
    registered:
     September 2004
    Status:
    offline
    last visit:
    30.06.08
    Posts:
    110
    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
  • Link to this postingPosted: 19.10.2005, 05:15
    Profile Homepage
    Imoq
    rank:
    Helper Helper
    registered:
     September 2004
    Status:
    offline
    last visit:
    30.06.08
    Posts:
    110
    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 :(
  • Link to this postingPosted: 19.10.2005, 12:22
    Profile Homepage
    jmvedrine
    rank:
    Professional Professional
    registered:
     January 2004
    Status:
    offline
    last visit:
    05.08.08
    Posts:
    632
    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.

Start ::  Extensions and Distributions Support ::  Modules ::  EZComments in Top List

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to Zikula