Working with SMF

I was working upon upgradate & modification of a forum powered by SMF. My first job was to upgrade the forum from SMF 1.1.14 to SMF 2.0.1. I found no difficulties in doing the upgardate. If you are not well accomplish with SMF upgrade process then here is a good instruction for you.

My next job was to customize the board icons. I googled a mod for this purpose. It is cbi v0.5 (Custom Board Icons). I downloaded the latest version of the mod which is cbi172.zip. I tried to follow the installation process for the mod but got no result. Then I tried for the manual installation instruction for SMF version 2.0.1. But it was my bad luck as I found the modification wasn’t compatible with version 2.0.1. So I had to spent some time with the code to make it work. This is what I had done.

First file is BoardIndex.template.php which within the Themes/default folder. Snipet-1 is the original & Snipet-2 is the modified code.

Snippet-1

[code lang=”php-brief”]
// If the board or children is new, show an indicator.
if ($board[‘new’] || $board[‘children_new’])
echo ‘
', $txt['new_posts'], '‘;
// Is it a redirection board?
elseif ($board[‘is_redirect’])
echo ‘
*‘;
// No new posts at all! The agony!!
else
echo ‘
', $txt['old_posts'], '‘;
[/code]

Snippet-2

[code lang=”php-brief”]
// If the board or children is new, show an indicator.
if ($board[‘new’] || $board[‘children_new’])
{
if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘on.png’) && file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘on2.png’))
$board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
else
$board_img_dir = ”;
echo ‘
', $txt['new_posts'], '‘;
}
// Is it a redirection board?
elseif ($board[‘is_redirect’])
{
if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘redirect.png’))
$board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
else
$board_img_dir = ”;
echo ‘
*‘;
}
// No new posts at all! The agony!!
else
{
if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘off.png’))
$board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
else
$board_img_dir = ”;
echo ‘
', $txt['old_posts'], '‘;
}
[/code]
Second file is MessageIndex.template.php which is also within the Themes/default folder. Snipet-1 is the original & Snipet-2 is the modified code.

Snippet-1

[code lang=”php-brief”]
// If the board or children is new, show an indicator.
if ($board[‘new’] || $board[‘children_new’])
echo ‘
', $txt['new_posts'], '‘;
// Is it a redirection board?
elseif ($board[‘is_redirect’])
echo ‘
*‘;
// No new posts at all! The agony!!
else
echo ‘
', $txt['old_posts'], '‘;[/code]

Snippet-2

[code lang=”php-brief”]
// If the board or children is new, show an indicator.
if ($board[‘new’] || $board[‘children_new’])
{
if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘on.png’) && file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘on2.png’))
$board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
else
$board_img_dir = ”;
echo ‘
', $txt['new_posts'], '‘;
}
// Is it a redirection board?
elseif ($board[‘is_redirect’])
{
if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘off.png’))
$board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
else
$board_img_dir = ”;
echo ‘
*‘;
}
// No new posts at all! The agony!!
else
{
if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘off.png’))
$board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
else
$board_img_dir = ”;
echo ‘
', $txt['old_posts'], '‘;
}
[/code]
Some of my friends asked me to release as mod, but I don’t have such intension. The reason behind doing such is that I have respect for Bigguy’s (creator of the mod) effort for creating and maintaining the mod. So this is a temporary solution till he releases compatiable version of this mod for SMF 2.0.1. If you like utilize the code choice is yours.

Tales from Lonely Highway is the forum I had worked for.

Leave a Reply