Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

How to add comments count to the Latest Articles Panel and Forum Threads Panel

Asked Modified Viewed 4,186 times
J
JakubG
J
JakubG 10
  • Newbie, joined since
  • Contributed 1 post on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

Can anybody help me with Latest Articles Pane and Forum Threads Panell? I want to add comments count to the article name and thread name in this panels. I want it to look like:

Name of the article [comments] [reads]

Name of the thread [reply's count] [reads]

Thanks!
0 replies

1 post

P
PHPar
P
PHPar 10
  • Member, joined since
  • Contributed 118 posts on the community forums.
  • Started 7 threads in the forums
answered
Member

This is First Panel for Articles

openside($locale['global_030']);
$result = dbquery(
   "SELECT ta.article_id, ta.article_reads, ta.article_subject, tac.article_cat_id, tac.article_cat_access FROM ".DB_ARTICLES." ta
   INNER JOIN ".DB_ARTICLE_CATS." tac ON ta.article_cat=tac.article_cat_id
   ".(iSUPERADMIN ? "" : "WHERE ".groupaccess('article_cat_access'))." AND article_draft='0' ORDER BY article_datestamp DESC LIMIT 0,5"
);
        $i = 0;
        echo "<table cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n<tr>\n";
       echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>Article</strong></td>\n";
       echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>Reads</strong></td>\n";
       echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>Comments</strong></td>\n";
       echo "</tr>\n<tr>";

if (dbrows($result)) {
   while($data = dbarray($result)) {
      $itemsubject = trimlink($data['article_subject'], 23);
        $row_color = ($i % 2 == 0 ? "tbl1" : "tbl2");

        echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".THEME_BULLET." <a href='".BASEDIR."articles.php?article_id=".$data['article_id']."' title='".$data['article_subject']."' class='side'>$itemsubject</a></td>\n";
      echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".$data['article_reads']."</td>\n";
      echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".dbcount("(comment_id)", DB_COMMENTS, "comment_type='A' AND comment_item_id='".$data['article_id']."'")."</td>\n";
      echo "</tr>\n";
        $i++;
   }
        echo "</table>\n";
} else {
   echo "<div style='text-align:center'>".$locale['global_031']."</div>\n";
}
closeside();


Merged on Apr 14 2015 at 20:11:44:
Forum Threads Panel with reads And replies


openside($locale['global_020']);
echo "<div class='side-label'><strong>".$locale['global_021']."</strong></div>\n";
$result = dbquery("
   SELECT tt.forum_id, tt.thread_postcount, tt.thread_views, tt.thread_id, tt.thread_subject, tt.thread_lastpost FROM ".DB_THREADS." tt
   INNER JOIN ".DB_FORUMS." tf ON tt.forum_id=tf.forum_id
   WHERE ".groupaccess('tf.forum_access')." AND tt.thread_hidden='0'
   ORDER BY thread_lastpost DESC LIMIT 5
");
        $i = 0;
        echo "<table cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n<tr>\n";
        echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_045']."</strong></td>\n";
       echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_046']."</strong></td>\n";
       echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>Reads</strong></td>\n";
        echo "</tr>\n<tr>\n";

if (dbrows($result)) {
   while($data = dbarray($result)) {
      $itemsubject = trimlink($data['thread_subject'], 23);
        $row_color = ($i % 2 == 0 ? "tbl1" : "tbl2");
        echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".THEME_BULLET." <a href='".FORUM."viewthread.php?thread_id=".$data['thread_id']."' title='".$data['thread_subject']."' class='side'>$itemsubject</a></td>\n";
        echo "<td width='1%' class='".$row_color."'>[".($data['thread_postcount'] - 1)."]</td>\n";
        echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".$data['thread_views']."</td>\n";
        echo "</tr>\n";
        $i++;
   }
    echo "</table>\n";
} else {
   echo "<div style='text-align:center'>".$locale['global_023']."</div>\n";
}
closeside();
Edited by PHPar on 14-04-2015 20:11,
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 1 post
  • Votes 0 votes
  • Topic users 2 members

2 participants

P
P
PHPar 10
  • Member, joined since
  • Contributed 118 posts on the community forums.
  • Started 7 threads in the forums
J
J
JakubG 10
  • Newbie, joined since
  • Contributed 1 post on the community forums.
  • Started 1 thread in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet