Jump to content

Tell me I've seen this..


skshost

Recommended Posts

<table width=100%>
{foreach key=num item=kbarticle from=$kbmostviews}
<tr><td>
[img=images/support/article.gif] [b][url="knowledgebase.php?action=displayarticle&catid={$kbarticle.category}&id={$kbarticle.id}"]{$kbarticle.title}[/url][/b]

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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} 

Link to comment
Share on other sites

  • 2 weeks later...

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