1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to use xenforo's header, footer etc?

Discussion in 'XenForo Development Discussions' started by Member 3639, Dec 16, 2011.

  1. Member 3639

    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?
  2. James

    James Well-Known Member

  3. wickedstangs

    wickedstangs Well-Known Member

  4. Member 3639

    Member 3639 Active Member

  5. jauburn

    jauburn Well-Known Member

    I'd like to know as well.
  6. meSingh

    meSingh Active Member

    Me too :)
  7. Marcus

    Marcus 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,
    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.
    meSingh likes this.
  8. meSingh

    meSingh Active Member

    Thanks Marcus, I will try this out.
  9. Marcus

    Marcus 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".

Share This Page