Daily Lucky Numbers:
9
12
15
38
45
46

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)
~action|arcade

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

Main code:

// Latest games block for SMF Arcade

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

$icons_per_row = 4;
$limit = 44;

$arcade = '
<div style="overflow: hidden;">
<div style="display: table;margin: 0 auto;padding: 1px;overflow: hidden;">
<div style="display: table-row;">';
list($count1, $imgFile) = array(0, '');

$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 {int:mylimit}', array('mylimit' => $limit)
);

while ($row = $smcFunc['db_fetch_assoc']($request)) {
$imgFile = isset($row['game_directory']) && $row['game_directory'] != '' ? $row['game_directory'] . '/' . $row['thumbnail'] : $row['thumbnail'];
if ($count1 > ($icons_per_row - 1)) {
$count1 = 0;
$arcade .= '
</div>
<div style="display: table-row;">';
}
$count1++;
$arcade .= '
<div style="display: table-cell;text-align: center;margin: 0 auto;border-spacing: 1px;">
<a href="' . $scripturl . '?action=arcade;sa=play;game=' . $row['id_game'] . '">
<img style="width:42px; height:42px;" src="' . $modSettings['gamesUrl'] . '/' . $imgFile . '" alt="' . $row['game_name'] . '" title="' . $row['game_name'] . '" />
</a>
</div>';
}

$smcFunc['db_free_result']($request);

$arcade .= '
</div>
</div>
</div>';

echo $arcade;

aquarius

Thank you @Chen Zhen

In case anyone needs to know, this can also be applied to Tiny Portal blocks or inserted into a template.

origon

Where do i change the code so it will be responsible like it is in random games?