Show Category in Top Ten?

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
cJohn
Posts: 7
Joined: Wed Nov 26, 2003 2:29 pm

Show Category in Top Ten?

Post by cJohn »

Hi. Awesome FAQ. Is there a way to show the category of an item in the list of Top 10 questions? I imagine I'll need to change the select statement for the top 10 in functions.php, but I'm notsure how to join into the rubric table.


TIA!

John
Thorsten
Posts: 15739
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

where should the category appear in the Top10? If you can told me that, I can post you a hack.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
cJohn
Posts: 7
Joined: Wed Nov 26, 2003 2:29 pm

Show Category in Top Ten?

Post by cJohn »

Thorsten wrote:Hi,

where should the category appear in the Top10? If you can told me that, I can post you a hack.

bye
Thorsten
Bless you =) Just to the right of "views:" would be great. My category names are short so truncating them won't be needed.

Thanks!
John
Thorsten
Posts: 15739
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi John,

here's the hack:

Code: Select all

function generateTopTen()
{
	global $db, $sids, $err_noTopTen, $msgViews, $sqltblpre;
    $categories = getCategories();
	$result = $db->query("SELECT DISTINCT ".$sqltblpre."faqdata.id, ".$sqltblpre."faqdata.lang, ".$sqltblpre."faqdata.rubrik, ".$sqltblpre."faqdata.thema, ".$sqltblpre."faqdata.rubrik, ".$sqltblpre."faqvisits.visits FROM ".$sqltblpre."faqvisits, ".$sqltblpre."faqdata WHERE ".$sqltblpre."faqdata.id = ".$sqltblpre."faqvisits.id AND ".$sqltblpre."faqdata.lang = ".$sqltblpre."faqvisits.lang AND ".$sqltblpre."faqdata.active = 'yes' ORDER BY ".$sqltblpre."faqvisits.visits DESC LIMIT 0,10");
	$output = "";
	if ($db->num_rows($result) > 0) {
		$i = 1;
		while ($row = $db->fetch_object($result)) {
			$output .= "<tr>\n\t<td class=\"topten\">\n";
			$output .= "\t<b>[".$i.".] ".$row->visits." ".$msgViews.":</b><br />".$categories[$row->rubrik]." <a href=\"".$_SERVER["PHP_SELF"]."?".$sids."aktion=artikel&rubrik=".$row->rubrik."&id=".$row->id."&lang=".$row->lang."\">".stripslashes(makeShorterText($row->thema, 8))."</a>\n";
			$output .= "\t</td>\n\t</tr>\n";
			$i++;
			}
		}
	else {
		$output = "<tr><td class=\"topten\">".$err_noTopTen."</td></tr>";
		}
	return $output;
}
It is not tested but it should work.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
cJohn
Posts: 7
Joined: Wed Nov 26, 2003 2:29 pm

Show Category in Top Ten?

Post by cJohn »

Perfect! Thanks so much for the quick response!

http://65.77.216.235/~clevela/faq/index.php

John
Post Reply