Create a custom page (php & template)

Historical

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?
 
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?

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

PHP:
public function actionfunctionName()
    {
        $variable = 'Hello World!';
      
        $viewParams = array(
            'variable' => $variable,
        );
              
       return $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.
 
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?

Thanks.
 
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?

Thanks.

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?
 
Top Bottom