Jump to content

Most Popular KB Articles


skshost

Recommended Posts

Someone asked me about this and I couldn't find where it was posted on the forums. Here's the query to get the most popular knowledgebase articles, put it on your homepage.tpl if you'd like. Then add the foreach statement from knowledgebase.tpl

{php}
// Get Articles with highest count
$i=0;
$client_query = "SELECT * FROM tblknowledgebase ORDER BY views LIMIT 10";
$result = mysql_query($client_query);
  while($row = mysql_fetch_array($result))
        {

        $kbmostviews_array[$i]['id'] = $row['id'];
        $kbmostviews_array[$i]['category'] = $row['category'];
        $kbmostviews_array[$i]['title'] = $row['title'];
        $kbmostviews_array[$i]['article'] = strip_tags($row['article']);
        $kbmostviews_array[$i]['views'] = $row['views'];
        $i++;
        }
//Pass the values to smarty   
$this->assign('kbmostviews',$kbmostviews_array);
{/php}

Link to comment
Share on other sites

  • 2 weeks later...

Hey joweb,

 

There seems to be a coding error in the following code:

 

$client_query = "SELECT * FROM tblknowledgebase ORDER BY views LIMIT 10";

 

If you use the code below instead of the above, you should get the desired result:

 

$client_query = "SELECT * FROM tblknowledgebase ORDER BY views DESC LIMIT 10";

 

skshost, perhaps you can update your original post to include the fix?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated