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
Show Category in Top Ten?
Moderator: Thorsten
Hi,
where should the category appear in the Top10? If you can told me that, I can post you a hack.
bye
Thorsten
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
amazon.de Wishlist
Show Category in Top Ten?
Bless you =) Just to the right of "views:" would be great. My category names are short so truncating them won't be needed.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
Thanks!
John
Hi John,
here's the hack:
It is not tested but it should work.
bye
Thorsten
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;
}
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist