Daily Lucky Numbers:

Category Block (Regular List)

Started by Chen Zhen, July 06, 2013, 03:00:53 PM

Previous topic - Next topic

Chen Zhen

Category block for SMF Arcade 2.5

Copy and paste this into a PHP code block (I suggest top or bottom block):

global $db_prefix, $modSettings, $context, $sourcedir, $scripturl, $smcFunc, $boardurl;

$requestit = array();
$rowit = array();
$category = array();
$jam = array();
$jam['arcade_category'] = array();

   $requestit = $smcFunc['db_query']('', '
      SELECT id_cat, cat_name, num_games, cat_order
      FROM {db_prefix}arcade_categories
      ORDER BY cat_order',

    while ($rowit = $smcFunc['db_fetch_assoc']($requestit))
      $jam['arcade_category'][] = array(
         'id' => $rowit['id_cat'],
         'name' => $rowit['cat_name'],
         'href' => $scripturl . '?action=arcade;category=' . $rowit['id_cat'],
         'games' => $rowit['num_games'],
         'order' => $rowit['cat_order'],
       Set table width & column variables  -
      change $NumberOfColumns for the number of columns across                  */

   echo '<table summary="cats_block2" border="0" cellspacing="2" cellpadding="5" class="smalltext" align="center" style="overflow: hidden;">

   foreach ($jam['arcade_category'] as $category)
      if ($columns <= $NumberOfColumns)  {
$gamepic_name = str_replace (" ", "_", $category['name']);
$gamepic_name = str_replace ("/", "-", $gamepic_name);
$category_pic = '<img src="' .$boardurl. '/Themes/default/images/arc_icons/'.$gamepic_name.'.gif" border="0" alt="~"  title="'.$category['name'].'" width="25" height="22" />';
            echo'   <td align="justify" width="320">', $category_pic," ",
               '<a href="', $category['href'], '">',$category['name'], '</a> (', $category['games'] , '

      if ($columns >= $NumberOfColumns)  {
         echo '</tr>';
         echo '<tr>';


   echo '<td>';
/* mt  */
echo '</td></tr></table>';


For Simple Portal users, you can have this show in your arcade (only) by selecting Advanced Options and enter the following into Custom Display Options:

The categories can also be displayed with small icons. Just name the icon the same as your category name except change any spaces to an underscore (case sensitive) and make sure it's in gif format.
Place the icons in: / Themes / default / images / arc_icons
The icons are set at 20 x 20 but this can be edited within the block.


Appreciate the code @Chen Zhen

Worked like a charm :)


hey chen i really like this block, and will it be compatable with the new arcade when it comes out...?

Chen Zhen

Yes this block will work with SMF Arcade 2.6.0



hey chen, what would i change in the code for this so the category link shows under the category image instead of beside it i was thinking or adding <br /> ??

Chen Zhen

You can try using a line break like that or you can perhaps wrap the link in div container.
div has the display of block by default which will drop down to the next line.