QUICK NEWS

{NEW} - A new css video is up.

{OLD} - New video courtesy of Skhilled, Thanks for posting it up.

Video of the moment:


Internal Links

SMF Sites

Quick Info

small board icon

Started by lesmond, Mar 22, 2019, 09:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

lesmond

What I am trying to do is add the small board icons that are displayed on 2.0.15 just above the info center.

This is how they are in 2.0.15


I want to add those to 2.1 I know they are called from BoardIndex.template.php so I copied that to my theme, and added the relevant code for those icons..

this is what I have added.
echo '
 <ul class="reset">
 <li class="floatleft"><img src="' . $settings['images_url'] . '/new_some.png" alt="" /> ', $txt['new_posts'], '</li>
 <li class="floatleft"><img src="' . $settings['images_url'] . '/new_none.png" alt="" /> ', $txt['old_posts'], '</li>
 <li class="floatleft"><img src="' . $settings['images_url'] . '/new_redirect.png" alt="" /> ', $txt['redirect_board'], '</li>
 </ul>
 </div>';

which works to a certain extent, but does not show the images just text, like so..


also I am getting errors in the log after doing so.

Type of error: Undefined
Undefined variable: settings
/Themes/test-theme/BoardIndex.template.php (Line 145)

and before you ask, I did add the images to the image folder in my theme  :vcool

Obviously I am doing something wrong  :dontknow  :emb

The only person who got all his work done by Friday was Robinson Crusoe

Bigguy

Would changing this:

/new_some.pngto this:

/images/new_some.pngWork at all. I know it already is in the code with this:

$settings['images_url']but that seems to be erroring. Not sure but maybe. How is it written in 2.0 :hwhat :dontknow
"It's the American dream....cause ya have to be asleep to believe it." - George Carlin

lesmond

this is how it is in 2.0.15

BoardIndex.template.php
echo '
<ul class="reset">
<li class="floatleft"><img src="' . $settings['images_url'] . 'new_some.png" alt="" /> ', $txt['new_posts'], '</li>
<li class="floatleft"><img src="' . $settings['images_url'] . 'new_none.png" alt="" /> ', $txt['old_posts'], '</li>
<li class="floatleft"><img src="' . $settings['images_url'] . 'new_redirect.png" alt="" /> ', $txt['redirect_board'], '</li>
</ul>
</div>';

And I have tried changing it too
/images/new_some.png

The only person who got all his work done by Friday was Robinson Crusoe

SychO

you need to add $settings to the the globals at the start of the function you're editing,

basically change this
function template_main()
{
global $context, $txt, $scripturl;

to this
function template_main()
{
global $context, $txt, $scripturl, $settings;

lesmond

Thats was it @SychO knew it was something simple :rgton

I also had to change the image_url as BG said too..
/new_some.png
Marked as Solved  :rgton

The only person who got all his work done by Friday was Robinson Crusoe

Bigguy

Hey glad ya got it. Not sure why they took that out really. Oh well. :)
"It's the American dream....cause ya have to be asleep to believe it." - George Carlin

lesmond

Quote from: Bigguy on Mar 22, 2019, 11:04 AMNot sure why they took that out really.

I agree, it's a small thing but I missed it.

The only person who got all his work done by Friday was Robinson Crusoe

Bigguy

Maybe a mod can be made out of this code. ;)
"It's the American dream....cause ya have to be asleep to believe it." - George Carlin

lesmond

I wonder, shouldn't be too hard,

* lesmond goes away scratching his head?

The only person who got all his work done by Friday was Robinson Crusoe

lesmond

#9
This is what I did, this is for the default theme, so if you dont have an BoardIndex.template.php in your other themes it will also show the text in those too, but not the images, unless you add them to your other themes.

In /Themes/default/BoardIndex.template.php find
function template_main()
{
 global $context, $txt, $scripturl;

Change too
function template_main()
{
 global $context, $txt, $scripturl, $settings;

Then find..
', template_button_strip($context['mark_read_button'], 'right'), '
 </div>';

add after..
{
 if ($context['user']['is_guest'])
 echo '
 <div id="posting_icons" class="flow_hidden">
 <ul class="reset">
 <li class="floatleft"><img src="', $settings['images_url'], '/new_none.png" alt="" width="20" height="20"/> ', $txt['old_posts'], '</li>
 <li class="floatleft"><img src="', $settings['images_url'], '/new_redirect.png" alt="" width="20" height="20"/> ', $txt['redirect_board'], '</li>
 </ul>
 </div>';

 }
    if ($context['user']['is_logged']) 
 echo '
 <div id="posting_icons">
 <ul class="reset">
 <li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_some.png" alt="" width="20" height="20"/> ', $txt['new_posts'], '</li>
 <li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_none.png" alt="" width="20" height="20"/> ', $txt['old_posts'], '</li>
 <li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_redirect.png" alt="" width="20" height="20"/> ', $txt['redirect_board'], '</li>
 </ul>
 </div>';
}

Add the images below to /Themes/default/images
They will be resized automatic.


and when logged out


If you want this to work in other custom themes you will have to add the same images below that match your board icons.

I am sure there is a better way to do this with css.

The only person who got all his work done by Friday was Robinson Crusoe

Bigguy

That's very cool. Right on. It's almost a mod now, lol.
"It's the American dream....cause ya have to be asleep to believe it." - George Carlin

lesmond

I forgot to add code for user and guest, when logged in/out, edited my post above.

The only person who got all his work done by Friday was Robinson Crusoe

live627

Niffy @lesmond! And now let's reuse the sprite.

Find

</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>';

Replace with

</div><!-- #boardindex_table -->
<div class="mark_read">
<div class="floatleft">';

if ($context['user']['is_logged'])
echo '
<div class="board_icon" style="width: 20px; vertical-align: sub;">
<a href="#" style="background-size: 45px; width: 20px; height: 20px;" class="board_on" title="', $txt['new_posts'], '"></a>
</div> ', $txt['new_posts'];

echo '
<div class="board_icon" style="width: 20px; vertical-align: sub;">
<a href="#" style="background-position: 0 -24px; background-size: 45px; width: 20px; height: 20px;" class="board_off" title="', $txt['old_posts'], '"></a>
</div> ', $txt['old_posts'], '
<div class="board_icon" style="width: 20px; vertical-align: sub;">
<a href="#" style="background-position: -24px -24px; background-size: 45px; width: 20px; height: 20px;" class="board_redirect" title="', $txt['redirect_board'], '"></a>
</div> ', $txt['redirect_board'], '
</div>';

// Show the mark all as read button?
if ($context['user']['is_logged'] && !empty($context['categories']))
echo '
', template_button_strip($context['mark_read_button'], 'right'), '';

echo '
<br class="clear">
</div>';

mark_read  needs its float removed

lesmond

#13
Thanks, I was trying to figure this out, but unless I am doing something wrong, I am getting to sets of icons now.



This is what I have after adding your code. I assume I should remove something?

</div><!-- #boardindex_table -->
 <div class="mark_read">
 <div class="floatleft">';

 if ($context['user']['is_logged'])
 echo '
 <div class="board_icon" style="width: 20px; vertical-align: sub;">
 <a href="#" style="background-size: 45px; width: 20px; height: 20px;" class="board_on" title="', $txt['new_posts'], '"></a>
 </div> ', $txt['new_posts'];

 echo '
 <div class="board_icon" style="width: 20px; vertical-align: sub;">
 <a href="#" style="background-position: 0 -24px; background-size: 45px; width: 20px; height: 20px;" class="board_off" title="', $txt['old_posts'], '"></a>
 </div> ', $txt['old_posts'], '
 <div class="board_icon" style="width: 20px; vertical-align: sub;">
 <a href="#" style="background-position: -24px -24px; background-size: 45px; width: 20px; height: 20px;" class="board_redirect" title="', $txt['redirect_board'], '"></a>
 </div> ', $txt['redirect_board'], '
 </div>';

 // Show the mark all as read button?
 if ($context['user']['is_logged'] && !empty($context['categories']))
 echo '
 ', template_button_strip($context['mark_read_button'], 'right'), '';

 echo '
 <br class="clear">
 </div>';

 {
 if ($context['user']['is_guest'])
 echo '
 <div id="posting_icons" class="flow_hidden">
 <ul class="reset">
 <li class="floatleft"><img src="', $settings['images_url'], '/new_none.png" alt="" width="20" height="20"/> ', $txt['old_posts'], '</li>
 <li class="floatleft"><img src="', $settings['images_url'], '/new_redirect.png" alt="" width="20" height="20"/> ', $txt['redirect_board'], '</li>
 </ul>
 </div>';

 }
    if ($context['user']['is_logged']) 
 echo '
 <div id="posting_icons">
 <ul class="reset">
 <li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_some.png" alt="" width="20" height="20"/> ', $txt['new_posts'], '</li>
 <li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_none.png" alt="" width="20" height="20"/> ', $txt['old_posts'], '</li>
 <li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_redirect.png" alt="" width="20" height="20"/> ', $txt['redirect_board'], '</li>
 </ul>
 </div>';
}

The only person who got all his work done by Friday was Robinson Crusoe

SychO

remove the set of code you added before live's :P