• Welcome, Guest. Please login.
 
Jan 24, 2021, 11:52 PM

News:

Gallery...Arcade....Media....Downloads....Articles. Plus a lot more to come.


cbi 2.0

Started by Bigguy, Dec 07, 2018, 05:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bigguy

Ok, so everyone knows that the cbi mod 1.9.5 (custom board icons) is only for 2.0.15 and below. I would like any ones help that can help to make version 2.0 for smf 2.1 It may be a bit early in the game to make a mod for 2.1 but I would like to take that chance.

I am not a code writer and I don't know if this mod would have to be re-written from the ground up or not. Some type of mod like this SHOULD be made for 2.1 though. I would like to start the ball rolling in this thread right here. :tc :good

Skhilled

I'm not much of a coder eiter, especially for starting from scratch. I can make some edits on things but that's it.

Bigguy

That's like me as well. I'm an editor, not a coder. All that has to happen with this is the mod has to change the code enough so it uses real images instead of sprites. 2.1 board icons use sprites. on, off, on2 and redirect are all one image. cbi uses the old way to do all those images. If we could find away to use the old way with 2.1 than the mod would be good to go I think.

Bigguy

I am going to attempt this real soon. I will post code here as I go. I wanna get started on this so hopefully sometime this weekend. The code should be able to be used in some form. I won't be able to do anything from scratch, lol.

chen_zhen

With most cases the SMF 2.1 branch has the ability to use both sprites or single images.
I'm the one that requested some of those changes long ago.

Doesn't the author support that mod anymore?
One can likely adjust that mod to do what you request.

I would attempt to use the hooks so there is no editing.
The arrays being edited come before their hooks so one could write code to adjust those arrays prior to any visible output from the templates.

Bigguy

Jan 04, 2019, 10:58 AM #5 Last Edit: Jan 04, 2019, 01:38 PM by Bigguy
This is my mod...check it out on the mod site. :yes

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

Bigguy

BoardIndex.template.php edit. This is the code that goes into the template:


   
/* Each board in each category's boards has:
new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
children (see below.), link_children (easier to use.), children_new (are they new?),
topics (# of), posts (# of), link, href, and last_post. (see below.) */
foreach ($category['boards'] as $board)
{
echo '
<tr id="board_', $board['id'], '" class="windowbg2">
<td class="icon windowbg"', !empty($board['children']) ? ' rowspan="2"' : '', '>
<a href="', ($board['is_redirect'] || $context['user']['is_guest'] ? $board['href'] : $scripturl . '?action=unread;board=' . $board['id'] . '.0;children'), '">';
// 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'))
$board_new_img = '/icons/' . $board['id'];
else
$board_new_img = '';
echo '
<img src="', $settings['images_url'], $board_new_img, '/', $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'])
{
if (file_exists($settings['theme_dir'] . '/images/icons/' . $board['id'] . '/' . $context['theme_variant_url'] . 'redirect.png'))
$board_redirect_img = '/icons/' . $board['id'];
else
$board_redirect_img = '';
echo '
<img src="', $settings['images_url'], $board_redirect_img, '/', $context['theme_variant_url'], 'redirect.png" alt="*" title="*" />';
}
// 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_nonew_img = '/icons/' . $board['id'];
else
$board_nonew_img = '';
echo '
<img src="', $settings['images_url'], $board_nonew_img, '/', $context['theme_variant_url'], 'off.png" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';
}
echo '
</a>
</td>

Now I will try to post the corresponding code from 2.1

Bigguy

Jan 04, 2019, 01:17 PM #7 Last Edit: Jan 04, 2019, 01:28 PM by Bigguy Reason: code tags
Now the code above has redirect and child boards icons in it as well so I think this is the right code from the BoardIndex.template in 2.1

/* Each board in each category's boards has:
 new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
 children (see below.), link_children (easier to use.), children_new (are they new?),
topics (# of), posts (# of), link, href, and last_post. (see below.) */
foreach ($category['boards'] as $board)
{
echo '
<div id="board_', $board['id'], '" class="up_contain ', (!empty($board['css_class']) ? $board['css_class'] : ''), '">
<div class="board_icon">', function_exists('template_bi_' . $board['type'] . '_icon') ? call_user_func('template_bi_' . $board['type'] . '_icon', $board) : template_bi_board_icon($board), '
</div>
<div class="info">', function_exists('template_bi_' . $board['type'] . '_info') ? call_user_func('template_bi_' . $board['type'] . '_info', $board) : template_bi_board_info($board);
// Show some basic information about the number of posts, etc.
echo '
</div>
<div class="board_stats">', function_exists('template_bi_' . $board['type'] . '_stats') ? call_user_func('template_bi_' . $board['type'] . '_stats', $board) : template_bi_board_stats($board), '
</div>
<div class="lastpost ', !empty($board['last_post']['id']) ? 'lpr_border' : 'hidden', '">', function_exists('template_bi_' . $board['type'] . '_lastpost') ? call_user_func('template_bi_' . $board['type'] . '_lastpost', $board) : template_bi_board_lastpost($board), '
</div>';
// Won't somebody think of the children!
if (function_exists('template_bi_' . $board['type'] . '_children'))
call_user_func('template_bi_' . $board['type'] . '_children', $board);
else
template_bi_board_children($board);
echo '
</div><!-- #board_[id] -->';
}
echo '
</div><!-- #category_[id]_boards -->
</div><!-- .main_container -->';
}
echo '
</div><!-- #boardindex_table -->';
// Show the mark all as read button?
if ($context['user']['is_logged'] && !empty($context['categories']))
echo '
<div class="mark_read">
', template_button_strip($context['mark_read_button'], 'right'), '
</div>';
}
/**
* Outputs the board icon for a standard board.
*
* @param array $board Current board information.
*/
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>';
}
/**
* Outputs the board icon for a redirect.
*
* @param array $board Current board information.
*/
function template_bi_redirect_icon($board)
{
global $context, $scripturl;
echo '
<a href="', $board['href'], '" class="board_', $board['board_class'], '"', !empty($board['board_tooltip']) ? ' title="' . $board['board_tooltip'] . '"' : '', '></a>';
}


If this is not it than I need to go back and find it again but it looks close.

Bigguy

Ok so I am attaching the 2.1 BoardIndex.template.php file that has just been edited. This has the old code in it from cbi.

Bigguy

Jan 04, 2019, 01:32 PM #9 Last Edit: Jan 04, 2019, 01:37 PM by Bigguy
Quote from: chen_zhen on Jan 04, 2019, 10:25 AMI would attempt to use the hooks so there is no editing.

That would be nice but I have only ever done that once and I had help with it. Btw, the file attached is a clean one from GH. I downloaded the package instead of using one of mine.

Bigguy

Ok, so that file did not work. I will check it out and see what errors I made. :(