Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Aiheen aloitti: Surf3rDud3 - marraskuu 23, 2011, 10:09:25 AP

Otsikko: Moving a button
Kirjoitti: Surf3rDud3 - marraskuu 23, 2011, 10:09:25 AP
I wonder if it was possible to move a button to the other side of a navigation bar? Instead of being on the left that one single button would be on the right while the rest would stay put... Look at the picture below... Thanks
Otsikko: Re: Moving a button
Kirjoitti: Sir Osis of Liver - marraskuu 23, 2011, 07:54:47 IP
Ok, this is an awful hack (hope Antechinus doesn't see it), but it werks gud!

In index.template.php find this:



// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div id="main_menu">
<ul class="dropmenu" id="menu_nav">';

foreach ($context['menu_buttons'] as $act => $button)
{
echo '
<li id="button_', $act, '">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';
if (!empty($button['sub_buttons']))




Change it to this:



// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div id="main_menu">
<ul class="dropmenu" id="menu_nav">';

foreach ($context['menu_buttons'] as $act => $button)
{

/// echo ' button = ' . $act . '<br>';

if ($act == 'mlist')

echo '
<li id="button_', $act, '" style="float: right;">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';

else

echo '
<li id="button_', $act, '">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';
if (!empty($button['sub_buttons']))



Substitute the action of the button you want to move right in if($act == 'mlist').  If you don't know the action, use the triple-slashed line to echo the values.

Otsikko: Re: Moving a button
Kirjoitti: ARG01 - marraskuu 24, 2011, 01:09:05 AP
Lainaus käyttäjältä: Krash. - marraskuu 23, 2011, 07:54:47 IP
......(hope Antechinus doesn't see it)......

Otsikko: Re: Moving a button
Kirjoitti: Surf3rDud3 - marraskuu 24, 2011, 11:04:08 AP
Is it illegal to do or something? Lol.
Otsikko: Re: Moving a button
Kirjoitti: Surf3rDud3 - marraskuu 24, 2011, 11:14:44 AP
Lol it works but.... it took out the look of the navigation... Look...

IF you need my original index.template its also below. :)
Otsikko: Re: Moving a button
Kirjoitti: Matthew K. - marraskuu 24, 2011, 12:26:04 IP
Of course it's not, he just didn't want Antechinus to see it because of it's possibly hackish method.
Lainaus käyttäjältä: Surf3rDud3 - marraskuu 24, 2011, 11:04:08 AP
Is it illegal to do or something? Lol.
Otsikko: Re: Moving a button
Kirjoitti: Sir Osis of Liver - marraskuu 24, 2011, 01:00:11 IP

This should do it.  I knocked that off in default theme between pizza & beer and folding my underwear.  Remember to substitute your action in if ($act == 'mlist').

Gotta run - the css police are after me.
Otsikko: Re: Moving a button
Kirjoitti: Surf3rDud3 - marraskuu 25, 2011, 01:19:04 AP
It just moves it to the last button and not to the other side... :/
Otsikko: Re: Moving a button
Kirjoitti: Sir Osis of Liver - marraskuu 25, 2011, 01:12:49 IP

Which theme are you using?

Otsikko: Re: Moving a button
Kirjoitti: Surf3rDud3 - marraskuu 25, 2011, 01:18:07 IP
Modified MysticJade_20
Otsikko: Re: Moving a button
Kirjoitti: Sir Osis of Liver - marraskuu 25, 2011, 01:55:00 IP

A favorite theme.  Took a quick look - it's in index.css.  Have to toddle off into the realworld, but I'll get to it later.

Otsikko: Re: Moving a button
Kirjoitti: Sir Osis of Liver - marraskuu 25, 2011, 10:25:47 IP
Just don't tell anyone where you got this -



// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<ul id="topnav" style="width: 99%;">';

foreach ($context['menu_buttons'] as $act => $button)
{

if ($act == 'mlist')

echo '
<li id="button_', $act, '" style="float: right; margin: 0 8px 0 0;">
<img src="Themes/MysticJade/images/custom/toolbar-div.png" style="float: left;">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';

else

echo '
<li id="button_', $act, '">
<a class="', $button['active_button'] ? 'active ' : '', '" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '><span>', $button['title'], '</span></a>';

Otsikko: Re: Moving a button
Kirjoitti: ARG01 - marraskuu 25, 2011, 11:21:11 IP
Lainaus käyttäjältä: Krash. - marraskuu 25, 2011, 01:55:00 IP

A favorite theme.  Took a quick look - it's in index.css.  Have to toddle off into the realworld, but I'll get to it later.



Don't you mean index.template.php?  ;)
Otsikko: Re: Moving a button
Kirjoitti: Sir Osis of Liver - marraskuu 25, 2011, 11:31:02 IP

If I did it the right way, it would be index.css.  Couldn't get the toolbar-divs where I wanted 'em, so I hacked it the old fashioned way.  Would be interesting to see someone do this with just css.


Otsikko: Re: Moving a button
Kirjoitti: ARG01 - marraskuu 26, 2011, 12:00:15 AP
Lainaus käyttäjältä: Krash. - marraskuu 25, 2011, 11:31:02 IP

If I did it the right way, it would be index.css.  Couldn't get the toolbar-divs where I wanted 'em, so I hacked it the old fashioned way.  Would be interesting to see someone do this with just css.

I don't think that it could be done purely with css. My opinion is that since the menu runs from Subs.php, a separate menu item to the right would need to also be coded in separately along with a separate addition in index.css for that specific menu item.
Too much code work for my knowledge.

;D

Otsikko: Re: Moving a button
Kirjoitti: Surf3rDud3 - marraskuu 26, 2011, 01:50:35 AP
Whoa thanks so much... sorry this was a hassle all for just button... i did have a problem with the image source for the toolbar_div but i fixed... But once again thanks :)