icons for each forum on forumhome

Started by jeremy420, November 18, 2005, 06:37:57 PM

Previous topic - Next topic

jeremy420

I was wondering if anyone could or knows how to put different icons next to each different forum title? I saw this hack for vbulletin and thought it would be cool for simple machines

screenshot



link to original thread
hxxp:www.vbulletin.org/forum/showthread.php?t=99500&page=1 [nonactive]

JayBachatero

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

1MileCrash

i dont think that's what he wants...look at the screen shot. they all have the same on/off.gif, but a different icon in the board description area. If that's what you want, you can accomplish this by simply putting the html in the board's description from the admin cp.
The only thing php can't do is tell you how much milk is left in the fridge.



jeremy420

Quote from: Tippmaster on November 18, 2005, 07:03:13 PM
i dont think that's what he wants...look at the screen shot. they all have the same on/off.gif, but a different icon in the board description area. If that's what you want, you can accomplish this by simply putting the html in the board's description from the admin cp.

Thanks, yes that is what I am looking for. I will try that out and see how it goes.

Anakin_holland

#4
Not trying to hijack this topic, but I have a question regarding the very same thing.

I got the idea of forum-specific icons because of this topic, and got to work.

Using the suggestion by Tippmaster I got the following:



To me this looks like crap... No layout whatsoever. Using some combination of <div> and valign don't work either because the icon and text are on the same line I guess?

I then got the idea to build it into the "function template_main()" in BoardIndex.template.php:

Code (php) Select
                                // No new posts at all!  The agony!!
                                else
                                        echo '<img src="', $settings['images_url'], '/off.gif" alt="', $txt[334], '" title="', $txt[334], '" border="0" />'
;

                                echo '</td>
                <td width="3%" align="center" valign="center">
                                        <img src="http://www.db-sat.com/smf/images/icons/icon_trashcan.jpg"></img>
                </td>
                <td align="left">
                                <b><a href="', $board['href'], '" name="b', $board['id'], '">', $board['name'], '</a></b><br />
                                        ', $board['description'];


That gave me this:



That's more like it! ;) Now, how to make this flexible... I could use an if-statement, but I wouldn't like this to be in the php-code, because every alternation or addition would require an edit on the php-script.

I therefor created a new field (called 'icon', type varchar, max 100 characters) in the table 'smf_boards', filled it and altered the code:

Code (php) Select
                <td width="3%" align="center" valign="center">
                                        <img src="http://www.db-sat.com/smf/images/icons/', $board['icon'], '"></img>
                </td>


But that doesn't work. The field $board['icon'] isn't filled. I guess I need to put a coupling between the variable and a SQL-query? So the question now is, where do I do that? And maybe this whole idea can be put into a MOD of some sort, so people can alter the icons of the forums in the Admin CP, and even upload them there? 8)

TIA!!

Anakin

Thantos

For SMF 1.1
File:  Subs-Boards.php
Function getBoardTree()
Find
        $request db_query("
                SELECT
                        IFNULL(b.ID_BOARD, 0) AS ID_BOARD, b.ID_PARENT, b.name AS bName, b.description, b.childLevel,
                        b.boardOrder, b.countPosts, b.memberGroups, b.ID_THEME, b.override_theme,
                        b.permission_mode, c.ID_CAT, c.name AS cName, c.catOrder, c.canCollapse
                FROM 
{$db_prefix}categories AS c
                        LEFT JOIN 
{$db_prefix}boards AS b ON (b.ID_CAT = c.ID_CAT)
                ORDER BY c.catOrder, b.childLevel, b.boardOrder"
__FILE____LINE__);

Replace with

        $request 
db_query("
                SELECT
                        IFNULL(b.ID_BOARD, 0) AS ID_BOARD, b.ID_PARENT, b.name AS bName, b.description, b.childLevel,
                        b.boardOrder, b.countPosts, b.memberGroups, b.ID_THEME, b.override_theme,
                        b.permission_mode, c.ID_CAT, c.name AS cName, c.catOrder, c.canCollapse, b.icon
                FROM 
{$db_prefix}categories AS c
                        LEFT JOIN 
{$db_prefix}boards AS b ON (b.ID_CAT = c.ID_CAT)
                ORDER BY c.catOrder, b.childLevel, b.boardOrder"
__FILE____LINE__);

Find

                        $boards
[$row['ID_BOARD']] = array(
                                
'id' => $row['ID_BOARD'],
                                
'category' => $row['ID_CAT'],
                                
'parent' => $row['ID_PARENT'],
                                
'level' => $row['childLevel'],
                                
'order' => $row['boardOrder'],
                                
'name' => $row['bName'],
                                
'memberGroups' => explode(','$row['memberGroups']),
                                
'description' => $row['description'],
                                
'count_posts' => empty($row['countPosts']),
                                
'theme' => $row['ID_THEME'],
                                
'override_theme' => $row['override_theme'],
                                
'use_local_permissions' => !empty($modSettings['permission_enable_by_board']) && $row['permission_mode'] == 1,
                                
'permission_mode' => empty($modSettings['permission_enable_by_board']) ? (empty($row['permission_mode']) ? 'normal' : ($row['permission_mode'] == 'no_polls' : ($row['permission_mode'] == 'reply_only' 'read_only'))) : 'normal',
                                
'prev_board' => $prevBoard
                        
);

Replace

                        $boards
[$row['ID_BOARD']] = array(
                                
'id' => $row['ID_BOARD'],
                                
'category' => $row['ID_CAT'],
                                
'parent' => $row['ID_PARENT'],
                                
'level' => $row['childLevel'],
                                
'order' => $row['boardOrder'],
                                
'name' => $row['bName'],
                                
'memberGroups' => explode(','$row['memberGroups']),
                                
'description' => $row['description'],
                                
'count_posts' => empty($row['countPosts']),
                                
'theme' => $row['ID_THEME'],
                                
'override_theme' => $row['override_theme'],
                                
'use_local_permissions' => !empty($modSettings['permission_enable_by_board']) && $row['permission_mode'] == 1,
                                
'permission_mode' => empty($modSettings['permission_enable_by_board']) ? (empty($row['permission_mode']) ? 'normal' : ($row['permission_mode'] == 'no_polls' : ($row['permission_mode'] == 'reply_only' 'read_only'))) : 'normal',
                                
'prev_board' => $prevBoard,
                                
'icon' => $row['icon']
                        );

Anakin_holland

I'm sorry for not mentioning, but I use 1.0.5.

I think this can get me places. I'll have a go at it.

Greetz!

Thantos

IIRC in 1.0 it was very similar.  I don't recall the file but the query itself was really close.  The second part should be not too far below the first part.

Anakin_holland

Found it!!  8)

In Sources/BoardIndex.php find (here line 61):

Code (php) Select
        // Find all boards and categories, as well as related information.
        $result_boards = db_query("
                SELECT
                        c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.description,
                        b.numPosts, b.numTopics, b.ID_PARENT,


Change to

Code (php) Select
        // Find all boards and categories, as well as related information.
        $result_boards = db_query("
                SELECT
                        c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.description,
                        b.numPosts, b.numTopics, b.ID_PARENT, b.icon,


And below that find (line 124 here):

Code (php) Select
                                $this_category[$row_board['ID_BOARD']] = array(
                                        'new' => empty($row_board['isRead']),
                                        'id' => $row_board['ID_BOARD'],
                                        'name' => $row_board['boardName'],
                                        'description' => $row_board['description'],
                                        'moderators' => array(),
                                        'link_moderators' => array(),
                                        'children' => array(),
                                        'link_children' => array(),
                                        'children_new' => false,
                                        'topics' => $row_board['numTopics'],
                                        'posts' => $row_board['numPosts'],
                                        'href' => $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0',
                                        'link' => '<a href="' . $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0">' . $row_board['boardName'] . '</a>'
                                   );


Change to

Code (php) Select
                                $this_category[$row_board['ID_BOARD']] = array(
                                        'new' => empty($row_board['isRead']),
                                        'id' => $row_board['ID_BOARD'],
                                        'name' => $row_board['boardName'],
                                        'description' => $row_board['description'],
                                        'moderators' => array(),
                                        'link_moderators' => array(),
                                        'children' => array(),
                                        'link_children' => array(),
                                        'children_new' => false,
                                        'topics' => $row_board['numTopics'],
                                        'posts' => $row_board['numPosts'],
                                        'href' => $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0',
                                        'link' => '<a href="' . $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0">' . $row_board['boardName'] . '</a>',
                                        'icon' => $row_board['icon']
                                );


All is well now!!

And maybe this could lead to a follow-up by someone, to please make this change available in "Manage Boards", so people only need to place the picture and name it in that section?

BTW, Jeremy, I hope this helped you as well?

Best regards,

Anakin

Anakin_holland

An update:

The text and solutions above only apply to the main-board... Here's the addition for child-boards:

In Sources/MessageIndex.php find

Code (php) Select
         $result = db_query("
                 SELECT
                         b.ID_BOARD, b.name, b.description, b.numTopics, b.numPosts,
                         m.posterName, m.posterTime, m.subject, m.ID_MSG, m.ID_TOPIC,
                         IFNULL(mem.realName, m.posterName) AS realName, " . (!$user_info['is_guest'] ? "


Alter to

Code (php) Select
         $result = db_query("
                 SELECT
                         b.ID_BOARD, b.name, b.description, b.numTopics, b.numPosts,
                         m.posterName, m.posterTime, m.subject, m.ID_MSG, m.ID_TOPIC, b.icon,
                         IFNULL(mem.realName, m.posterName) AS realName, " . (!$user_info['is_guest'] ? "


And below that find

                                         'topics' => $row_board['numTopics'],
                                         'posts' => $row_board['numPosts'],
                                         'href' => $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0',
                                         'link' => '<a href="' . $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0">' . $row_board['name'] . '</a>'
                                 );


and alter to

                                         'topics' => $row_board['numTopics'],
                                         'posts' => $row_board['numPosts'],
                                         'href' => $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0',
                                         'link' => '<a href="' . $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0">' . $row_board['name'] . '</a>',
                                         'icon'=> $row_board['icon']
                                 );


After that, the variable $board['icon']  is usable in MessageIndex.template.php as well!

Greetz!

vdubbia

Quote from: Thantos on November 19, 2005, 11:03:48 AM
For SMF 1.1
File:  Subs-Boards.php
Function getBoardTree()
Find
        $request db_query("
                SELECT
                        IFNULL(b.ID_BOARD, 0) AS ID_BOARD, b.ID_PARENT, b.name AS bName, b.description, b.childLevel,
                        b.boardOrder, b.countPosts, b.memberGroups, b.ID_THEME, b.override_theme,
                        b.permission_mode, c.ID_CAT, c.name AS cName, c.catOrder, c.canCollapse
                FROM 
{$db_prefix}categories AS c
                        LEFT JOIN 
{$db_prefix}boards AS b ON (b.ID_CAT = c.ID_CAT)
                ORDER BY c.catOrder, b.childLevel, b.boardOrder"
__FILE____LINE__);

Replace with

        $request 
db_query("
                SELECT
                        IFNULL(b.ID_BOARD, 0) AS ID_BOARD, b.ID_PARENT, b.name AS bName, b.description, b.childLevel,
                        b.boardOrder, b.countPosts, b.memberGroups, b.ID_THEME, b.override_theme,
                        b.permission_mode, c.ID_CAT, c.name AS cName, c.catOrder, c.canCollapse, b.icon
                FROM 
{$db_prefix}categories AS c
                        LEFT JOIN 
{$db_prefix}boards AS b ON (b.ID_CAT = c.ID_CAT)
                ORDER BY c.catOrder, b.childLevel, b.boardOrder"
__FILE____LINE__);

Find

                        $boards
[$row['ID_BOARD']] = array(
                                'id' => $row['ID_BOARD'],
                                'category' => $row['ID_CAT'],
                                'parent' => $row['ID_PARENT'],
                                'level' => $row['childLevel'],
                                'order' => $row['boardOrder'],
                                'name' => $row['bName'],
                                'memberGroups' => explode(','$row['memberGroups']),
                                'description' => $row['description'],
                                'count_posts' => empty($row['countPosts']),
                                'theme' => $row['ID_THEME'],
                                'override_theme' => $row['override_theme'],
                                'use_local_permissions' => !empty($modSettings['permission_enable_by_board']) && $row['permission_mode'] == 1,
                                'permission_mode' => empty($modSettings['permission_enable_by_board']) ? (empty($row['permission_mode']) ? 'normal' : ($row['permission_mode'] == 'no_polls' : ($row['permission_mode'] == 'reply_only' 'read_only'))) : 'normal',
                                'prev_board' => $prevBoard
                        
);

Replace

                        $boards
[$row['ID_BOARD']] = array(
                                'id' => $row['ID_BOARD'],
                                'category' => $row['ID_CAT'],
                                'parent' => $row['ID_PARENT'],
                                'level' => $row['childLevel'],
                                'order' => $row['boardOrder'],
                                'name' => $row['bName'],
                                'memberGroups' => explode(','$row['memberGroups']),
                                'description' => $row['description'],
                                'count_posts' => empty($row['countPosts']),
                                'theme' => $row['ID_THEME'],
                                'override_theme' => $row['override_theme'],
                                'use_local_permissions' => !empty($modSettings['permission_enable_by_board']) && $row['permission_mode'] == 1,
                                'permission_mode' => empty($modSettings['permission_enable_by_board']) ? (empty($row['permission_mode']) ? 'normal' : ($row['permission_mode'] == 'no_polls' : ($row['permission_mode'] == 'reply_only' 'read_only'))) : 'normal',
                                'prev_board' => $prevBoard,
                                'icon' => $row['icon']
                        );


I apologize for resurrecting this, but I can't figure out where to put the forum icons for this recode.

Advertisement: