Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Topic started by: Dominus Arbitrationis on July 03, 2019, 12:18:21 PM

Title: 2.1 RC2 Changing Board Icons
Post by: Dominus Arbitrationis on July 03, 2019, 12:18:21 PM
Hi,

Is it possible to set the board icons to a custom icon for each board? My current 2.0.15 forum has this set up (Not on a default theme, however), but the 2.1 rc2 test forum doesn't appear to have this functionality.
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Kindred on July 03, 2019, 12:30:48 PM
if 2.0.x has it, you did it by a mod -- this is not a standard feature in any version of SMF.
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Sir Osis of Liver on July 03, 2019, 12:35:31 PM
You can try this mod -

https://custom.simplemachines.org/mods/index.php?mod=4224
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Dominus Arbitrationis on July 03, 2019, 01:12:05 PM
Quote from: Sir Osis of Liver on July 03, 2019, 12:35:31 PM
You can try this mod -

https://custom.simplemachines.org/mods/index.php?mod=4224


I like that mod, but it doesn't appear to support custom images. Am I just missing something there?
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Kindred on July 03, 2019, 01:25:19 PM
You do realize that you apply custom images by CSS alone?
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Dominus Arbitrationis on July 03, 2019, 02:02:31 PM
Yes. I was just hoping there would be a better system for it, like if there were an option when modifying boards to change the image to any you select. That way, people who don't know/can't be bothered to learn CSS can edit the images.
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Kindred on July 03, 2019, 02:06:25 PM
in that case...   In theory this one should still work...

https://custom.simplemachines.org/mods/index.php?mod=511
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Bigguy on July 03, 2019, 02:31:15 PM
No it doesn't. I have been trying to update it but at the present moment I have had no luck.
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Diego Andrés on July 15, 2019, 01:32:57 PM
For the default theme you could do something like this:

Code (BoardIndex.template.php (Search)) Select
// If the board or children is new, show an indicator.
if ($board['new'] || $board['children_new'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'on', $board['new'] ? '' : '2', '.png" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" />';
// Is it a redirection board?
elseif ($board['is_redirect'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'redirect.png" alt="*" title="*" />';
// No new posts at all! The agony!!
else
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'off.png" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';


Code (Replace) Select
// If the board or children is new, show an indicator.
if ($board['new'] || $board['children_new'])
echo '
<img src="', $settings['images_url']. '/boardicons/', $board['id'],'.png" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" />';
// Is it a redirection board?
elseif ($board['is_redirect'])
echo '
<img src="', $settings['images_url']. '/boardicons/', $board['id'],'.png" alt="*" title="*" />';
// No new posts at all! The agony!!
else
echo '
<img src="', $settings['images_url']. '/boardicons/', $board['id'],'.png" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';


Then add a new folder boardicons in Themes/{yourtheme}/images
And you add an image for each board by id. E.g. ?board=1.0, 1 is that forum ID so you save your icon as 1.png
Also could change this to your preference

// No new posts at all! The agony!!
else
echo '
<img src="', $settings['images_url']. '/boardicons/', $board['id'],'.png" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';


Like using
// No new posts at all! The agony!!
else
echo '
<img src="', $settings['images_url']. '/boardicons/', $board['id'],'_off.png" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';

So you can have 1_off.png for the off icon, or simply add an inline style for opacity

Regards
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Bigguy on July 15, 2019, 01:46:55 PM
If that code is for 2.1, you pretty much just updated the cbi mod, lol.
Title: Re: 2.1 RC2 Changing Board Icons
Post by: Diego Andrés on July 15, 2019, 01:50:18 PM
That was for 2.0 I didn't read the title tbh
But it's pretty much the same just add your icon instead of using css

function template_bi_board_icon($board)
{
global $context, $scripturl;

echo '
<a href="', ($context['user']['is_guest'] ? $board['href'] : $scripturl . '?action=unread;board=' . $board['id'] . '.0;children'), '" class="board_', $board['board_class'], '"', !empty($board['board_tooltip']) ? ' title="' . $board['board_tooltip'] . '"' : '', '></a>';
}