• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

[How-To] Create New Help Menus

James

Well-known member
This tutorial will show you how to create a new help menu. For the purposes of this tutorial, we will create an About Us menu.

Step 1:
Create a folder named HelpMenu in library
Inside HelpMenu, create 2 folders named ControllerPublic and Listener
Inside ControllerPublic, create a file named Help.php
Inside Listener, create a file named LoadClassController.php

Your directory tree should be:
-| Library
--| HelpMenu
---| ControllerPublic
----| Help.php
---| Listener
----| LoadClassController.php

Inside the file named Help.php, we need to create a function to resolve the new About Us help item, which will be this code:
Code:
<?php

class HelpMenu_ControllerPublic_Help extends XFCP_HelpMenu_ControllerPublic_Help
{
public function actionAbout()
{
return $this->_getWrapper('about',
$this->responseView('XenForo_ViewPublic_Help_About', 'help_about')
);
}
}
Save and close that file.

Open up LoadClassController.php inside Listener and add the following code:
Code:
<?php

class HelpMenu_Listener_LoadClassController
{
    public static function extendHelpController($class, array &$extend)
    {
        if ($class == 'XenForo_ControllerPublic_Help')
        {
            $extend[] = 'HelpMenu_ControllerPublic_Help';
        }
    }
}
Save that file.

Now, ensuring debug mode is enabled, navigate to admin.php?code-event-listeners/add and input the following information:
Listen to Event: load_class_controller
Execute Callback: HelpMenu_Listener_LoadClassController :: extendHelpController

Add your description and callback execution order as appropriate.

Now, once you've saved that, create a new template named help_about, populate it with your information and you can find it readily available at XFroot/help/about.

Now you need to edit the templates to add the links.
Navigate to help_wrapper
Find:
Code:
<li><a href="{xen:link help/trophies}" class="{xen:if "{$selected} == 'trophies'", 'secondaryContent', 'primaryContent'}">{xen:phrase trophies}</a></li>
Add underneath:
Code:
<li><a href="{xen:link help/about}" class="{xen:if "{$selected} == 'about'", 'secondaryContent', 'primaryContent'}">About Us</a></li>

The end result is this:
Screenshot_1.webp

If you have any questions, please post below.

Also, to add these links to other areas of the help menu (such as sub-navigation, drop-down), see Brogan's tutorial: Add new entries to the help page | XenForo Community
 
Q: I already have a page node with my about us information - how do I transfer it to the Help menu?
A: Open up Help.php, find:
Code:
return $this->_getWrapper('about',
$this->responseView('XenForo_ViewPublic_Help_About', 'help_about')
Replace the help_about at the end with the name of your template (such as _page_node.nodeid). Example:
Code:
return $this->_getWrapper('about',
$this->responseView('XenForo_ViewPublic_Help_About', '_page_node.3')

Q: I want to change the URL from /help/about to /help/about-us - how do I do it?
A: Open up Help.php, find:
Code:
public function actionAbout()
Change to:
Code:
public function actionAboutUs()
You will then need to re-edit the help_wrapper template and update the {xen:link help/about} to {xen:link help/about-us}.
 
Only edits to the help_wrapper template will need to be reapplied, the rest of the information is stored externally as an add-on.
 
Nice work James, another thing added to my "To Do" list.
You can actually add page node templates instead of creating new ones, if you see the first question. You could just take your page node and use that template instead of creating the new one!
 
I get this error with this using 1.1 beta4 on a dev install:

Fatal error: Class 'HelpMenu_ControllerPublic_Help' not found in /home/*******/public_html/library/XenForo/FrontController.php on line 405
 
I'll give this another shot later today. I don't see why it wouldn't work in 1.1.

EDIT: Works fine for me in 1.1 beta 3, when I upgrade to beta 4 I'll re-test it.
 
It says the class isn't found. Can you post the name of your classes and functions in the LoadClassController.php and the Listener.php files, and also in the code event listener?
 
Go figure... today it just worked. Bugs or something....

James, how would you adjust this to add further pages to the help menu? Is it simply rename the primary directory name, create the same files over and over, change the controller to match the directory and repeat for each page?
 
Go figure... today it just worked. Bugs or something....

James, how would you adjust this to add further pages to the help menu? Is it simply rename the primary directory name, create the same files over and over, change the controller to match the directory and repeat for each page?

No its even easier than that. Just open helpmenu_controllerpublic_help and add actionPageName() and specify the return template. I'll post another example when I'm on the pc, I'm mobile at the minute.
 
No its even easier than that. Just open helpmenu_controllerpublic_help and add actionPageName() and specify the return template. I'll post another example when I'm on the pc, I'm mobile at the minute.
Cheers... I'll wait until your example, so I don't screw it up... thanks for this James, this will actually really help neaten things up with FAQ's and such knowing how to create additional pages in this area...
 
Code:
 public function actionAbout()
{
    return $this->_getWrapper('about', $this->responseView('XenForo_ViewPublic_Help_About', 'help_about')
);
}
change the about in actionAbout() to whatever you want your page named, such as actionMeetTheStaff (which creates help/meet-the-staff) then change the help_about to your new template for your meet the team content and change ViewPublic_Help_About to ViewPublic_Help_MeetTheTeam

Hope this helps, took me ages on mobile. I'll create a new one tomorrow.
 
So I could stack the one file, ie:
PHP:
<?php
 
class HelpMenu_ControllerPublic_Help extends XFCP_HelpMenu_ControllerPublic_Help
{
public function actionAbout()
{
    return $this->_getWrapper('about', $this->responseView('XenForo_ViewPublic_Help_About', 'help_about')
);
}
 
public function actionRules()
{
    return $this->_getWrapper('rules', $this->responseView('XenForo_ViewPublic_Help_Rules', 'help_rules')
);
}
}
 
Ok, next question... :eek:

How can I get the page name to register as part of the page title? If you click on the bbcode default page, the pages title will say BBcode which will also be reflected in the browser head title.

Pages created via this only show the forum title entered in options on every page, not an actual page title.
 
Ok, next question... :eek:

How can I get the page name to register as part of the page title? If you click on the bbcode default page, the pages title will say BBcode which will also be reflected in the browser head title.

Pages created via this only show the forum title entered in options on every page, not an actual page title.
You do this in your template. For example, your template for About Us you'd put at the top of your template:
<xen:title>About Us</xen:title>

Look inside the help_bb_code and help_smilies etc templates to see the standard layout for help menus.
 
Top Bottom