How to use xenforo's header, footer etc?

Member 3639

Active member
Okay guys I am working on a currently semi-simple addon that i need and no one else seems to be doing either...

How would I go about including the xenforo header and footer, basically having a blank page I can code in between?


Well-known member
1. Add a route prefix in ACP Developer modus to /mypage and point it to your my_route.php file
2. in my_route.php file you point to your my_controllerPublic.php file
class YOURADDON_Route_Prefix_YOURFILE implements XenForo_Route_Interface
public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
  $action = $router->resolveActionWithIntegerParam($routePath, $request, 'test_id');
  return $router->getRouteMatch('YOURADDON_ControllerPublic_Index', $action, ' mypage ');
Class names have to be named after your internal file / directory structure.
3. in my_controllerPublic.php file you create a public function actionIndex (). This function is executed once a user browses to /mypage
4. in this my_controllerPublic.php file you do your php, and then output it with this
 $viewParams = array(
  'var1' => $test,
  'var2' => $test2,
  return $this->responseView('Xenforo_ViewPublic_Index', 'your_template_name', $viewParams);
Your template your_template_name renders within template PAGE_CONTAINER, so it will have your header and footer. $test and $test2 are accessible in your template as var1 and var2.


Well-known member
1. Just take notice that actually this class "YOURADDON_Route_Prefix_YOURFILE" is in this directory:

Xenforo_Route_Prefix_Thread.php would be YOURMAINXENFORODIRECTORY/library/Xenforo/Route/Prefix/Thread.php

2. In return $this->responseView('Xenforo_ViewPublic_Index', 'your_template_name', $viewParams); the first parameter Xenforo_ViewPublic_Index will be used as fallback if you also put something like "tomato_Index" as parameter. Lots of addons put any name there and then the file does not exist. That is not important because of the fallback. Important is your template name, and the variables you give to the template.

3. You give parameters to the template with /mypage/234324 as a link. This number can be fetched in your ControllerPublic php file with input_filter_single function, where you search for "test_id". You told in the route "$action = $router->resolveActionWithIntegerParam($routePath, $request, 'test_id');" actually, that the number ("integerParam") will be named "test_id".