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

  1. // If the board or children is new, show an indicator.
  2. if ($board[‘new’] || $board[‘children_new’])
  3.   echo
  4. <img title="’, $txt[‘new_posts’], ‘" src="’, $settings[‘images_url’], ‘/’, $context[‘theme_variant_url’], ‘on’, $board[‘new’] ? : ‘2’, ‘.png" alt="’, $txt[‘new_posts’], ‘" />’;
  5. // Is it a redirection board?
  6. elseif ($board[‘is_redirect’])
  7.   echo
  8. <img title="*" src="’, $settings[‘images_url’], ‘/’, $context[‘theme_variant_url’], ‘redirect.png" alt="*" />’;
  9. // No new posts at all! The agony!!
  10. else
  11.   echo
  12. <img title="’, $txt[‘old_posts’], ‘" src="’, $settings[‘images_url’], ‘/’, $context[‘theme_variant_url’], ‘off.png" alt="’, $txt[‘old_posts’], ‘" />’;

Snippet-2

  1. // If the board or children is new, show an indicator.
  2. if ($board[‘new’] || $board[‘children_new’])
  3. {
  4.    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’))
  5.       $board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
  6.    else
  7.       $board_img_dir = ;
  8.    echo
  9.         <img src="’, $settings[‘images_url’], ‘/’, $board_img_dir, $context[‘theme_variant_url’], ‘on’, $board[‘new’] ? : ‘2’, ‘.png" alt="’, $txt[‘new_posts’], ‘" title="’, $txt[‘new_posts’], ‘" />’;
  10. }
  11. // Is it a redirection board?
  12. elseif ($board[‘is_redirect’])
  13. {
  14.    if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘redirect.png’))
  15.       $board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
  16.    else
  17.       $board_img_dir = ;
  18.    echo
  19.         <img src="’, $settings[‘images_url’], ‘/’, $board_img_dir, $context[‘theme_variant_url’], ‘redirect.png" alt="*" title="*" />’;
  20. }
  21. // No new posts at all! The agony!!
  22. else
  23. {
  24.    if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘off.png’))
  25.       $board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
  26.    else
  27.       $board_img_dir = ;
  28.    echo
  29.         <img src="’, $settings[‘images_url’], ‘/’, $board_img_dir, $context[‘theme_variant_url’], ‘off.png" alt="’, $txt[‘old_posts’], ‘" title="’, $txt[‘old_posts’], ‘" />’;
  30. }

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

  1. // If the board or children is new, show an indicator.
  2. if ($board[‘new’] || $board[‘children_new’])
  3.   echo
  4. <img title="’, $txt[‘new_posts’], ‘" src="’, $settings[‘images_url’], ‘/’ .$context[‘theme_variant_url’], ‘on’, $board[‘new’] ? : ‘2’, ‘.png" alt="’, $txt[‘new_posts’], ‘" />’;
  5. // Is it a redirection board?
  6. elseif ($board[‘is_redirect’])
  7.   echo
  8. <img title="*" src="’, $settings[‘images_url’], ‘/’ .$context[‘theme_variant_url’], ‘redirect.png" alt="*" />’;
  9. // No new posts at all! The agony!!
  10. else
  11.   echo
  12. <img title="’, $txt[‘old_posts’], ‘" src="’, $settings[‘images_url’], ‘/’ .$context[‘theme_variant_url’], ‘off.png" alt="’, $txt[‘old_posts’], ‘" />’;

Snippet-2

  1. // If the board or children is new, show an indicator.
  2. if ($board[‘new’] || $board[‘children_new’])
  3. {
  4.    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’))
  5.       $board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
  6.    else
  7.       $board_img_dir = ;
  8.    echo
  9.            <img src="’, $settings[‘images_url’], ‘/’, $board_img_dir, $context[‘theme_variant_url’], ‘on’, $board[‘new’] ? : ‘2’, ‘.png" alt="’, $txt[‘new_posts’], ‘" title="’, $txt[‘new_posts’], ‘" />’;
  10. }
  11. // Is it a redirection board?
  12. elseif ($board[‘is_redirect’])
  13. {
  14.    if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘off.png’))
  15.       $board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
  16.    else
  17.       $board_img_dir = ;
  18.    echo
  19.            <img src="’, $settings[‘images_url’], ‘/’, $board_img_dir, $context[‘theme_variant_url’], ‘redirect.png" alt="*" title="*" />’;
  20. }
  21. // No new posts at all! The agony!!
  22. else
  23. {
  24.    if (file_exists($settings[‘theme_dir’] . ‘/images/icons/’ . $board[‘id’] . ‘/’ . $context[‘theme_variant_url’] . ‘off.png’))
  25.       $board_img_dir = ‘icons/’. $board[‘id’] . ‘/’;
  26.    else
  27.       $board_img_dir = ;
  28.    echo
  29.            <img src="’, $settings[‘images_url’], ‘/’, $board_img_dir, $context[‘theme_variant_url’], ‘off.png" alt="’, $txt[‘old_posts’], ‘" title="’, $txt[‘old_posts’], ‘" />’;
  30. }

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