Snowman Posted June 27, 2013 Share Posted June 27, 2013 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} 0 Quote Link to comment Share on other sites More sharing options...
Snowman Posted June 27, 2013 Author Share Posted June 27, 2013 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 /> 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.