Gearbest Banner

Latest Games Block

Started by Chen Zhen, July 06, 2013, 02:59:32 PM

previous topic - next topic

Chen Zhen

SMF 2.0 Rcx and SMF Arcade

Latest games block (icons only):

Create a new php block...

Enter this for custom display options:
(For viewing on portal - leave this line blank)
Code Select

~action|arcade


Change '$icons_per_row' to equal the amount preferred
Change 'LIMIT' to equal the amount preferred

Main code:
Code Select

// Latest games block by Underdog
// For SMF2.0 Rcx and SMF Arcade
// Arcade page already has latest game command
// - it just needs a button put on the arcade page
// Suggested placement is on portal

global $db_prefix, $scripturl, $modSettings, $boardurl, $smcFunc;
   $arcade = '<table><tr>';
   $count1 = 0;
   $icons_per_row = 4;

   $request = $smcFunc['db_query']('', '
   SELECT game.id_game, game.game_name, game.game_directory, game.thumbnail
      FROM {db_prefix}arcade_games AS game
     ORDER BY game.id_game DESC   
      LIMIT 44', array()
   );
   while ($row = $smcFunc['db_fetch_assoc']($request))
   {
      if ($count1 > ($icons_per_row - 1)){$count1 = 0; $arcade .= '</tr><tr>';}
      $count1 =$count1 + 1;
      $arcade .= '<td align="center"><a href="' . $scripturl . '?action=arcade;sa=play;game=' . $row['id_game'] . '"><img style="width:42px; height:42px;" src="' . $boardurl . '/Games/';
      if(isset($row['game_directory']) && $row['game_directory'] != '') {$arcade .= $row['game_directory'] . '/';}
      $arcade .= $row['thumbnail'] . '" alt="'.$row['game_name'].'" title="'.$row['game_name'].'" /></a></td>';   
   }
$smcFunc['db_free_result']($request);   
   $arcade .= '</tr></table>';
   echo $arcade;