Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: Antechinus in Juli 04, 2012, 07:29:36 NACHMITTAGS

Titel: Advanced sidebar menus
Beitrag von: Antechinus in Juli 04, 2012, 07:29:36 NACHMITTAGS
Someone on the team move this to Tips and Tricks for me. I don't have those permissions any more. :P

Anyway, what I've done is add flyouts to the old sidebar menus so that they give all the same access options as the new drop menus, but in a more familiar format that some people may prefer. These menus will run with or without javascript, including full keyboard accessibility on the flyouts. Up to you if you want the jQuery/Superfish bits.

Screenshot is attached. Code is below. Do wotcha like. :)

GenericMenu.template.php:

Find:
// Is this the current area, or just some area?
if ($i == $menu_context['current_area'])
{
echo '
<strong><a href="', isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i, $menu_context['extra_parameters'], '">', $area['label'], '</a></strong>';

if (empty($context['tabs']))
$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
}
else
echo '
<a href="', isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i, $menu_context['extra_parameters'], '">', $area['label'], '</a>';

echo '
</li>';
}


Replace:
// Is this the current area, or just some area?
if ($i == $menu_context['current_area'])
{
echo '
<strong><a href="', isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i, $menu_context['extra_parameters'], '">', !empty($area['subsections']) ? '<span class="floatright">&#187;</span>' : '', $area['label'], '</a></strong>';

if (empty($context['tabs']))
$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
}
else
echo '
<a href="', isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i, $menu_context['extra_parameters'], '">', !empty($area['subsections']) ? '<span class="floatright">&#187;</span>' : '', $area['label'], '</a>';
// Is there any subsections?
if (!empty($area['subsections']))
{
echo '
<ul class="thingy">';

foreach ($area['subsections'] as $sa => $sub)
{
if (!empty($sub['disabled']))
continue;

$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;

echo '
<li>
<a ', !empty($sub['selected']) ? 'class="active" ' : '', 'href="', $url, $menu_context['extra_parameters'], '"><span>', $sub['label'], '</span></a>
</li>';
}

echo '
</ul>';
}
echo '
</li>';
}


index.css:

Find:
#left_admsection
{
width: 160px;
float: left;
padding-right: 10px;
}


Replace:
#left_admsection
{
width: 180px;
float: left;
padding-right: 10px;
}


That part is just because it works a bit better with a little extra width, to accommodate the subsection indicators with some of the longer links. Use your own judgement.

Anyway, next bit, still in index.css:

Find:
.left_admmenu li
{
padding: 0 0 0 0.5em;
}
.left_admmenu
{
margin-bottom: 0.5em;
}


Replace:
/*Begin sidebar flyout coding. */
.left_admmenu {
margin-bottom: 6px;
}
.left_admmenu li {
padding: 0 0 0 6px;
line-height: 2em;
}
.left_admmenu li a {
display: block;
}
.left_admmenu li strong a {
color: #333;
}
.left_admmenu li:hover a, .left_admmenu li.sfhover a {
color: #d37b00;
}
.left_admmenu li {
position: relative;
}
.left_admmenu li ul {
position: absolute;
z-index: 90;
top: 0;
left: -9999px;
width: 170px;
padding: 4px;
border-top: 1px solid #e7eaef;
border-left: 1px solid #e7eaef;
border-right: 1px solid #aaa;
border-bottom: 1px solid #aaa;
background: #fff;
border-radius: 0 4px;
box-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}
.left_admmenu li:hover ul, .left_admmenu li.sfhover ul {
left: 170px;
}
.left_admmenu li li {
padding: 0 0 0 0;
}
.left_admmenu li li a {
white-space: pre;
padding: 0 6px;
display: block;
}
.left_admmenu li:hover li a, .left_admmenu li.sfhover li a {
display: block;
color: #346;
}
.left_admmenu li li a:focus {
background: #fff;
width: 155px;
margin-left: 10169px;
}
.left_admmenu li li:hover a:focus, .left_admmenu li li.sfhover a:focus {
margin-left: 0;
}
/*End sidebar flyout coding. */


If you want the jQuery/Superfish effects, you'll also need some tweaks to index.template.php plus the relevant javascript files.

Index.template.php:

Find:
// RTL languages require an additional stylesheet.
if ($context['right_to_left'])
echo '
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/rtl.css" />';


Add after:

// Jquery Librarys
echo '
<script type="text/javascript" src="', $settings['theme_url'], '/scripts/jquery-1.7.1.min.js"></script>';

// Note that the Superfish function seems to like being called by the full syntax.
// It doesn't appear to like being called by short syntax. Please test if contemplating changes.
echo '
<script type="text/javascript" src="', $settings['theme_url'], '/scripts/hoverIntent.js"></script>
<script type="text/javascript" src="', $settings['theme_url'], '/scripts/superfish.js"></script>';


That assumes you are calling jQuery locally. Suit yourself on that detail.

Next, find:
var ajax_notification_text = "', $txt['ajax_in_progress'], '";
var ajax_notification_cancel_text = "', $txt['modify_cancel'], '";
// ]]></script>';


Add after:

echo '
<script type="text/javascript"><!-- // --><![CDATA[
$(document).ready(function() {
$("ul.dropmenu, ul.left_admmenu").superfish();
});
// ]]></script>';


That assumes you want the jQ effect on the main drop menus too. Again, suit yourself.

Screenshot below. Zipped js files attached.
Titel: Re: Advanced sidebar menus
Beitrag von: Robert. in Juli 05, 2012, 03:41:40 VORMITTAG
Moved. :) They look great, nice work :)
Titel: Re: Advanced sidebar menus
Beitrag von: Nityananda Maity in August 06, 2012, 04:31:07 VORMITTAG
I get Template Parse Error!. Please help me
Attachments
http://www.hopmoney.com/files/error.zip (http://www.hopmoney.com/files/error.zip)
Titel: Re: Advanced sidebar menus
Beitrag von: Shambles in August 06, 2012, 04:42:28 VORMITTAG
Lose the rogue } on line 102




Titel: Re: Advanced sidebar menus
Beitrag von: Nityananda Maity in August 06, 2012, 05:02:06 VORMITTAG
Zitat von: Shambles™ in August 06, 2012, 04:42:28 VORMITTAG
Lose the rogue } on line 102
tried it but not works correctly
http://hopmoney.com/files/Administration%20Center.pdf
Titel: Re: Advanced sidebar menus
Beitrag von: Shambles in August 06, 2012, 05:04:53 VORMITTAG
Zitat von: Nityananda Maity in August 06, 2012, 05:02:06 VORMITTAG
Zitat von: Shambles™ in August 06, 2012, 04:42:28 VORMITTAG
Lose the rogue } on line 102
tried it but not works correctly
http://hopmoney.com/files/Administration%20Center.pdf
You still get a parse error?  ???
Titel: Re: Advanced sidebar menus
Beitrag von: kat in August 06, 2012, 05:12:03 VORMITTAG
That's kinda groovy, Ant!

Opera somewhat screws it up, by having the link pop-out, though, obscuring things. :(
Titel: Re: Advanced sidebar menus
Beitrag von: Nityananda Maity in August 06, 2012, 05:19:34 VORMITTAG
Hi friends,
My problem is solved. After removing the last '}' from replacement edit on GenericMenu.template.php (provided on tutorial above).
Thanks all
Titel: Re: Advanced sidebar menus
Beitrag von: Antechinus in August 06, 2012, 05:21:32 VORMITTAG
Zitat von: K@ in August 06, 2012, 05:12:03 VORMITTAG
That's kinda groovy, Ant!

Opera somewhat screws it up, by having the link pop-out, though, obscuring things. :(

Must admit I didn't test it in Opera. I'm not surprised that Opera somewhat screws it up. Opera has a habit of doing things like that. :D

I'll take a look at it later.
Titel: Re: Advanced sidebar menus
Beitrag von: kat in August 06, 2012, 05:25:49 VORMITTAG
Oh, it's not a problem!

I have the thing enabled, so that I don't go to places that have hidden links, kinda thing.

When people do the GO HERE! (http://www.simplemachines.org) thing, I prefer to see where the links take me, before I click it. ;)
Titel: Re: Advanced sidebar menus
Beitrag von: Antechinus in August 06, 2012, 05:55:46 VORMITTAG
Ok, so exactly what do you mean by "link pop-out"?
Titel: Re: Advanced sidebar menus
Beitrag von: kat in August 06, 2012, 06:02:12 VORMITTAG
When you place the cursor over a link, the links gets displayed.

Not a pop-out, really. Just a thing that... er... pops up. (If that makes any sense)

It's not like I can take a screeny, really. Although, one of those apps that takes a screeny with a hot-key might do it, I s'pose. I'll see if I can find one. :)
Titel: Re: Advanced sidebar menus
Beitrag von: kat in August 06, 2012, 06:12:57 VORMITTAG
Good ol' Irfanview. :)

Screeny attached.
Titel: Re: Advanced sidebar menus
Beitrag von: Antechinus in August 06, 2012, 06:30:56 VORMITTAG
Ah. Nothing I can do about that, since it's hard-coded into the browser. Why not just have the url showing in the status bar, like Firefox and Chrome? Much neater.

ETA: Hey just checked. Opera shows the url in the status bar by default. :P
Titel: Re: Advanced sidebar menus
Beitrag von: kat in August 06, 2012, 06:48:38 VORMITTAG
I must have a setting, somewhere, then.

I'll have a fiddle.

/me suggests we have this as standard in future versions of SMF. :)
Titel: Re: Advanced sidebar menus
Beitrag von: Antechinus in August 06, 2012, 06:59:59 VORMITTAG
I don't mind if it's in 2.1, but there would probably need to be more than one person in favour of it. It was just an idea that occurred to me, so I thought I'd see what the feedback was.
Titel: Re: Advanced sidebar menus
Beitrag von: kat in August 06, 2012, 03:29:14 NACHMITTAGS
It's a VAST improvement!

Not sure it'd be worth the hassle, for you, modding it up, for v2, though.
Titel: Re: Advanced sidebar menus
Beitrag von: kingston250 in Oktober 19, 2012, 12:46:48 NACHMITTAGS
That's good news your problem is solved.
Titel: Re: Advanced sidebar menus
Beitrag von: GraphicJunki in Dezember 22, 2012, 03:09:51 VORMITTAG
Great tip thanks :)
Titel: Re: Advanced sidebar menus
Beitrag von: jpbeauty in Dezember 23, 2012, 03:47:40 VORMITTAG
Thanks for the technique.
Titel: Re: Advanced sidebar menus
Beitrag von: kingston250 in Januar 02, 2013, 12:23:35 NACHMITTAGS
Hmmmmm some interesting tips and helpful.