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

Create a custom page (php & template)

Discussion in 'XenForo Development Discussions' started by Namoh, Jan 13, 2016.

  1. Namoh

    Namoh Member

    I'm wondering how I would go on about if I for example wanted to create a page called page.php and put it in the appropriate folder in the xenforo one and attach a template to it so I can modify the content of that page through the ACP? For example add HTML to it and then the css in EXTRA.css?
  2. wang

    wang Well-Known Member

    That would include several steps. You will have to create your controller public class which must extend the XenForo_ControllerPublic_Abstract class. Then you must create your public route file which must extend the XenForo_Route_Interface class.

    Then in your controller public file you enter the code that you want to execute and then you must register your variables to use in your custom template. e.g

    public function actionfunctionName()
    $variable 'Hello World!';
    $viewParams = array(
    'variable' => $variable,
    $this->responseView('XenForo_ViewPublic_Base''template' $viewParams); 
    Then in your custom template you can use {$variable}, which will output Hello World! And of course, replace template with the actual name of your template. And the same goes for the other example names.

    If you want to use html in your variable you can use: {xen:raw $variable}. If you want to use bbcode then you must create your view file, which must match the path entered for responseView function. E.g.

    return $this->responseView('Your_Class_ViewPublic_Name', 'template' , $viewParams);

    and then enter some code to the view file to parse the bbcode, but we can get to that later.
  3. v8td

    v8td Member

    I created a new page as node in some category. In Page Options is Template HTML where i specified a template i created. It's a simple HTML. But instead of HTML in page appears the name of tempate, as i specified.
    I need to create a class and method to render the page as i did for bbcode?

    If i specified html code for an anchor in Template HTML, it's ok, appear the anchor... Obviously it's not a good html editor...
    Or how can i specify the template i defined for this?

  4. wang

    wang Well-Known Member

    How did you specify the template? Can you please post it here? With regard to your other question, do you want to parse bbcode in pages?

Share This Page