Skip to main content
Easiest way to add a menu button and page Started by Trekkie101 · · Read 5243 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic

Easiest way to add a menu button and page

Hi,

I've trawled through the forum here and looked at a few mods but there seems to be about 10 ways to accomplish the following and where I go in the code - its all being depreciated. What is the simplest and most best practice way to:

1. Add a Menu button for all (including guests) on the community drop down. (see attachment)


2. Add that page so that it shows up. I'm just adding a table that pulls in information from another server - is there an easy way to generate everything elk above and below?

Re: Easiest way to add a menu button and page

Reply #1

I puzzled over that as well, and finally decided the easiest way was to create the page and then add a "news" blurb with an html link to it..

I'll be lurking to see if someone provides a more elegant solution that doesn't require writing an add-on or something similar..

// Deep inside every dilemma lies a solution that involves explosives //

Re: Easiest way to add a menu button and page

Reply #2

Quote from: Steeley – I puzzled over that as well, and finally decided the easiest way was to create the page and then add a "news" blurb with an html link to it..

I'll be lurking to see if someone provides a more elegant solution that doesn't require writing an add-on or something similar..

The addon packaging is easier :joy:

I can manually hack it into a template and force it into the action array.

However I think there’s a nicer way with hooks and templates but I’m not smart enough.

Re: Easiest way to add a menu button and page

Reply #3

You can do it with TinyPortal or SimplePortal if you use a php article.

If you don’t want to use one of those two then integrate_menu_buttons is for the drop down and integrate_actions should do the page with you extending the standard page controller.

Re: Easiest way to add a menu button and page

Reply #4

That’s probably what I’ll do once 2.0 is out the door, I jumped on early :nerd:

Thanks for the pointers!

Re: Easiest way to add a menu button and page

Reply #5

If you want it to look like the rest of the forum, with the menu strip etc, then you need to use hooks and some template.  If its just a url/link to somewhere, it can be just that,  like what the help button on this site does, it simply goes to the github wiki

I'll post a simple addon package for you to look at in the AM (thats my AM)  ... It will be nothing fancy, just something to get you going.  It will add a button in that first menu area, and then go to a page when selected.  Those hooks are be the same on 1.1 and 2.0 so it should just work:trade_mark:

Re: Easiest way to add a menu button and page

Reply #6

Here is a very basic example, but a couple of notes.

I did not add language support, the button name is hard coded, if that is important then you would need to install the appropriate language file or if lucky find the name in one of the core language strings.

I only used the integrate_menu_buttons hook.  This gives you access to the massive menu array so you can add / remove / replace / etc  The hook calls the function in MyButton.subs.php, in that I added them menu after search but you could add it anywhere you want.

Since this is a simple example, the action is called mybutton and the system will automatically look for a Mybutton.php class file in the controller directory and call its action_index  From there you can initiate, do checks, dispatch

Not knowing what you want to output I simply loaded the Error template file and used the fatal_error template, not what you will want but simply to show how to load and call.  You can add and call your own template or maybe find one of the generic ones that suits your need.  But the basics are load $context in your controller and then use those values in your template.

Attached is the file, should work ....

Re: Easiest way to add a menu button and page

Reply #7

Hero! It explains everything quite easily for me!

So does adding a hook therefore trigger something in the database to look for it?

My work around was just adding it to Menu.subs.php but I had a feeling that wasn't how we were doing things now :D

Re: Easiest way to add a menu button and page

Reply #8

Worked brilliant! Thank you so much.

So I added a template to make it slightly easier.

Made it visible to guests.

Got confused on where you could do includes, turns out you need to be on the top level, or give a full path. Easily sorted.

Integrated live Park Waits onto the site with ease.

The benefit of it being a package also, is that I can continue to use the dev versions live and flick it on / off at will.

Re: Easiest way to add a menu button and page

Reply #9

Awesome, glad it helped you out!