Jump to content

displaying top knowledgebase articles


Snowman

Recommended Posts

im wondering if anyone knows how to retrieve the top results from the knowledgebase for display on other pages of the helpdesk other than the Knowledgebase itself?

 

I have created a new page within the templates system and tried to use the code from the knowledgebase template but it seems that the variables dont seem to be available according to {debug}

 

the variable is {$kbmostviews}

Link to comment
Share on other sites

nevermind i worked it out...

 

for anyone wanting to do this

 

{include file="$template/subheader.tpl" title=$LANG.knowledgebasepopular}

{php}
// Get Articles with highest count
$i=0;
$client_query = "SELECT * FROM tblknowledgebase ORDER BY views DESC LIMIT 5";
$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}

{foreach key=num item=kbarticle from=$kbmostviews}
<div class="row">
<img src="images/article.gif"><a href="{if $seofriendlyurls}knowledgebase/{$kbarticle.id}/{$kbarticle.urlfriendlytitle}.html{else}http://knowledgebase.php/?action=displayarticle&catid={$kbarticle.category}&id={$kbarticle.id}{/if}" class="fontsize2"><strong>{$kbarticle.title}</strong></a>
{$kbarticle.article|truncate:100:"..."}
{$LANG.knowledgebaseviews}:
{$kbarticle.views}<br />
</div>
{/foreach}
<br />

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