Easiest way to add a menu button and page
July 30, 2022, 11:48:25 am
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 – July 30, 2022, 03:10:41 pm
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..
Re: Easiest way to add a menu button and page
Reply #3 – July 30, 2022, 03:48:54 pm
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 #6 – July 31, 2022, 09:05:45 am
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 #8 – July 31, 2022, 10:27:26 am
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 – July 31, 2022, 11:00:04 am
Awesome, glad it helped you out!