News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Custom menu buttons?

Started by Maxkranen, September 26, 2010, 01:48:22 AM

Previous topic - Next topic

Maxkranen

Hey there  ;D

Would there be any way i can add custom buttons to the menu with "Home, Profile, Logout etc." ? I mean, a few buttons, if you click on them you go to a link which i 'configured' in the ACP  O:)

Thanks for any help.


Kays


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Dragon3360

I need to set a menu button with "_blank" as it's target so to have the URL open in a seperate window.

Would I achieve it like this?

Example:         

'chat' => array(
'title' => 'Chat',
'a target'=> '_blank',
'href' => 'http:mydomain.com/chat/index.php',
'show' => true,


Thanks for any assistance.

:)

IceXaos


Dragon3360

#5
Thank You "Ice"!  ;)

:)

QuoteSolved!

IceXaos

No problem.  OP, if you're done here, please tick this solved.

Maxkranen


Dragon3360

OK, now for a more difficult menu button function.

I need a chat menu button which opens our chatroom in a seperate sized window instead of a seperate full browser window. Can do in HTML, just not sure how to perform the function with PHP with SMF's menu operation code.

HTML example code:
<a href="http://client0.addonchat.com/chat.php?id=000000"
onclick="window.open('http://client0.addonchat.com/chat.php?fs&id=000000',
'addonchat','width=720,height=515,status=no,scrollbars=no,menubar=no,resizable=yes');
return false">Chat</a>


Current SMF menu button code (thanks to "Ice")
'chat' => array(
'title' => 'Chat',
'target'=> '_blank',
'href' => 'http:mydomain.com/chat/index.php',
'show' => true,


Would this approach be correct?

'chat' => array(
'title' => 'Chat',
'href' => 'http://client0.addonchat.com/chat.php?id=000000',
'onclick'='window.open('http://client0.addonchat.com/chat.php?fs&id=000000',
'addonchat','width=720,height=515,status=no,scrollbars=no,menubar=no,resizable=yes');
return false',
'show' => true,


I fear not as "onclick" is a java function call right?

Any help on this would be appreciated

Thanks

Kays

For the onclick, etc, you will need to add all of that to href so it's one long string.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

KensonPlays

Or you could ALSO try this:
http://arantormods.com/index.php?action=media;sa=item;in=34
It's Dream Menu, if you decide to install Dream Portal, be sure to uninstall Dream Menu first!

Dragon3360

Quote from: Kays on September 28, 2010, 09:06:54 AM
For the onclick, etc, you will need to add all of that to href so it's one long string.

What would be the correct syntax to add the string following:

'href' =>

When trying as is after the above menu href call I get a parse error.




Kays

The parser error is probably because you didn't escape any of the single quotes.

Here's something I use in my Member Notepad mod. The main button will open a new page, or tab for Firefox. This is in case the user has JavaScript disabled. The sub-button will open it in a popup window the way you wish.


'notepad' => array(
'title' => $txt['notepad'],
'href' => $scripturl . '?action=notepad',
'show' => $context['allow_notepad'],
'target' => $context['browser']['is_firefox'] ? '_new' : '_blank',
'sub_buttons' => array(
'notes_popup' => array(
'title' => $txt['notes_popup'],
'href' => 'javascript:void(0)" onclick="window.open(\'' . $scripturl . '?action=notepad\',\'PopupWindow\',\'height=600,width=750,scrollbars=1,resizable=1\');return false;',
'show' => $context['allow_notepad'],
),
),
),

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Dragon3360

#13
Quote from: Kays on September 29, 2010, 09:28:19 AM
The parser error is probably because you didn't escape any of the single quotes.

Thank you for your response Kays,

Please forgive my newbie ignorance in PHP syntax, I'm learning. When you refer to escaping single quotes, is this achieved through the use of "\" as seen in the example you provided? So my updated code should be as follows?

'href' => 'javascript:void(0) "onclick="window.open( \ 'http://client0.addonchat.com/chat.php?fs&id=000000\ ', \ 'addonchat \'  , \ 'width=720,height=515,status=no,scrollbars=no,menubar=no,resizable=yes\');return false',

Want to also acknowledge "Kcmartz" for providing the link to the Dream Menu mod. I have downloaded it and will be applying it to our test site which emulates our operational site. Thank you for the link to it. It looks like a fantastic mod for working with and customizing the menu system of SMF.

Anyones reference to a quality beginners PHP book would be welcomed. I've purchased several, but they seem to not explain PHP syntax well.

Thanks for everyones help  ;)

Kays

Yes like that by adding a backslash before the single quote. But without a space in between.

That line is a string encased in single quotes. Adding a single quote in the string will terminate that line unexpectedly. The backslash tells the parser to ignore that single quote.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Dragon3360

Thank you Kays! .... works perfectly  ;) I also added the target variable for firefox browsers as you suggested in your example.

SOLVED!

Advertisement: