PDA

View Full Version : Tell me I've seen this..



skshost
03-04-07, 06:56 AM
Most popular Knowledgebase articles on the support homepage. I assumed that I'd find a checkbox in admin to turn it on, do I have to build this?

Adam
03-04-07, 07:33 AM
Most popular Knowledgebase articles on the support homepage. I assumed that I'd find a checkbox in admin to turn it on, do I have to build this?

Hey,

You have to built it your self...

From,
Adam

skshost
03-04-07, 07:41 AM
<table width=100%>
{foreach key=num item=kbarticle from=$kbmostviews}
<tr><td>
images/support/article.gif {$kbarticle.title} (knowledgebase.php?action=displayarticle&catid={$kbarticle.category}&id={$kbarticle.id})

{$kbarticle.article|truncate:50:"..."}

<font style="color:#A8A8A8;font-size:10px;">{$LANG.knowledgebaseviews}: {$kbarticle.views}</FONT>
</td></tr>
{/foreach}
</table>

Looks simple, but I get nothing outside of knowledgebase.php

yabado
03-04-07, 10:54 AM
I do not believe that page provides the necessary smarty variables for you to use that code.

Add {debug} to that page and reload. A popup window will reveal to you what is available to the template.

You can, however, use {php} code to add it yourself.

Just do a search for all articles and base the order on the number of views.

Then save all the results into an array, pass it to smarty, then use the same code above to display.

I plan to do this myself. When I do I will post the code on the forums.

yabado
03-04-07, 11:16 AM
OK, try this.

Here is the php code you need to add to the top of your clientareahome.tpl page.




{php}

// Get Articles with highest count

$client_query = "SELECT * FROM tblknowledgebase ORDER BY views LIMIT 10";
$result = mysql_query($client_query);
while($row = mysql_fetch_array($result))
{

$kbmostviews_array['id'] .= $row['id'];
$kbmostviews_array['category'] .= $row['category'];
$kbmostviews_array['title'] .= $row['title'];
$kbmostviews_array['article'] .= $row['article'];
$kbmostviews_array['views'] .= $row['views'];
}

//Pass the values to smarty
$this->assign('kbmostviews',$kbmostviews_array);


{/php}



Then you can use the exact same template code to display the articles.

I have not tested it yet, but it should work.[/code]

skshost
03-04-07, 09:35 PM
Didn't work, just shows # of views and same value for article name. I think I see what your doing though.

yabado
03-06-07, 01:15 PM
OK, this works.




{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}

skshost
03-08-07, 03:26 AM
Thanks alot!

bucketshop
03-16-07, 01:46 PM
Isn't this already in the current version of WHMCS? What I would like to do is get the "highest rated" articles that have the most votes.

I would also like to get the most recent articles. How would I go about that?

bucketshop
03-16-07, 01:47 PM
I didn't read in enough detail. I now see the OP wanted it on the support "homepage".