Daily Lucky Numbers:

Drop-Down Category Block

Started by Chen Zhen, July 06, 2013, 02:56:25 PM

Previous topic - Next topic

Chen Zhen

Drop-Down categories block:

SMF 2.0 Rcx edit

This will give you a nice drop-down category menu inside a php block.
You can check out the one in this arcade for the example.

Create a php block...

Custom Display Options :
(For viewing on portal - leave this line blank)


Main Code:

// Category php block for smf 2.0/smf arcade
// Written by Underdog
// Drop-down menu style taken from Hambil/Jeza
// Other variables are set in case another menu style is desired

global $scripturl, $smcFunc;
$count = 1;
$cat_name = array();
$cat_link = array();
$cat_drop = array();
$where1 = $scripturl . '?action=arcade;category=';
echo '<form action="', $scripturl, '?action=arcade" method="post">
<select name="category" style="font-size: 100%; color: white;" onchange="JavaScript:submit()">
<option value="">View By Category</option>';

$request = $smcFunc['db_query']('', '
   SELECT id_cat, cat_name, num_games, cat_order
      FROM {db_prefix}arcade_categories
     ORDER BY cat_order', 
   while ($row = $smcFunc['db_fetch_assoc']($request))
$count = $row['id_cat'];
$cat_name[$count] = $row['cat_name'];
$cat_link[$count] = $where1 . $count;
$cat_drop[$count] = '<a href="' . $cat_link[$count] .'">'.$cat_name[$count].'</a>';

echo '
<option value="', $count, '">', $cat_name[$count], '</option>';


echo '


Note: You can change your font color with this part of the above code:

<select name="category" style="font-size: 100%; color: white;"