XF 1.5 New Misc page

abdfahim

Well-known member
I want to create a new miscellaneous page with the route "misc/new-page" which should follow the structure of Contact Us page (without the form). I don't need any thing to return as the page would be a static page with the content in the mytest_new_page template.

Is it enough to extend the XenForo_ControllerPublic_Misc class?

Library/MyTest/Extend/ControllerPublic/Misc.php:
PHP:
class MyTest_Extend_ControllerPublic_Misc extends XFCP_MyTest_Extend_ControllerPublic_Misc
{
    public function actionNewPage()
    {
        return $this->responseView('XenForo_ViewPublic_Misc_NewPage', 'mytest_new_page', null);
    }
}


Listener.php
PHP:
class MyTest_Listener
{
    public static function load_class_controller ($class, array &$extend)
    {
        if ($class == 'XenForo_ControllerPublic_Misc')
        {
            $extend[] = 'MyTest_Extend_ControllerPublic_Misc';
        }
    }
}
 
That seems roughly correct. You shouldn't provide a third argument to responseView though (or if you do, it has to be an array).

You can make your class loading a bit more efficient by using an event hint (for XenForo_ControllerPublic_Misc).
 
Thanks a lot, @Mike. Yes, I'll use an even hint.

Off the topic, though I never faced this issue so far, I always wonder if I extend to two different classes inside my Listener.php, what even hint I should use.
 
Back
Top Bottom