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

I can't get my alternative page container working

Umit

Active member
#1
Lets make the thread hot again :p

i couldnt apply this to my test page;

Code:
<?php

class XenForo_testing_helloworld extends XenForo_ControllerPublic_Abstract
{
    public static function actionIndex(XenForo_ControllerPublic_Abstract  $controller, XenForo_ControllerResponse_Abstract &$response)
    {

        $mytestContent = date("l, F d, Y h:i" ,time());
        $t = $controller->_input->filterSingle('t', XenForo_Input::STRING);

        $params = array(
            'mytestContent'  => $mytestContent,
            't' => $t
        );

          $response->params = array_merge(
            $response->params,
            $params
        );
how can i do?
 

Arik

Well-known member
#6
Lets make the thread hot again :p

i couldnt apply this to my test page;

Code:
<?php

class XenForo_testing_helloworld extends XenForo_ControllerPublic_Abstract
{
    public static function actionIndex(XenForo_ControllerPublic_Abstract  $controller, XenForo_ControllerResponse_Abstract &$response)
    {

        $mytestContent = date("l, F d, Y h:i" ,time());
        $t = $controller->_input->filterSingle('t', XenForo_Input::STRING);

        $params = array(
            'mytestContent'  => $mytestContent,
            't' => $t
        );

          $response->params = array_merge(
            $response->params,
            $params
        );
how can i do?
Are you copying that code from somewhere? There are a few things wrong with it.

1. Controller functions aren't static. Take that word out.
2. Remove the parameters being passed to the actionIndex method.
3. Instead of $controller->_input...do $this->_input (after all, you're in the controller class)
4. Replace the entire $response->params part with a call to the responseView.

PHP:
return $this->responseView('ViewPublic_Class_Doesnt_Need_To_Exist',
'template_name',
$params,
array('container_template' => 'your_custom_container_template');
 

Umit

Active member
#7
Are you copying that code from somewhere? There are a few things wrong with it.
Hi, found it in the forum and i wanted to work on it.

I've applied what you said and here is the error xenforo shows me:

call_user_func_array() expects parameter 1 to be a valid callback, non-static method XenForo_testing_helloworld::actionIndex() should not be called statically

XenForo_Application::handlePhpError()
call_user_func_array() in XenForo/ControllerPublic/Page.php at line 46
XenForo_ControllerPublic_Page->actionIndex() in XenForo/FrontController.php at line 310
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
XenForo_FrontController->run() in /Applications/MAMP/htdocs/xenforo/index.php at line 17
file structure: myXFinstall/Library/XenForo/testing/helloworld.php

Code:
<?php

class XenForo_testing_helloworld extends XenForo_ControllerPublic_Abstract
{
    public function actionIndex()
    {

        $mytestContent = date("l, F d, Y h:i" ,time());
        $t = $this->_input->filterSingle('t', XenForo_Input::STRING);

        $params = array(
            'mytestContent'  => $mytestContent,
            't' => $t
        );

        return $this->responseView('ViewPublic_Class_Doesnt_Need_To_Exist',
            'test-template',
            $params,
            array('container_template' => 'test_container')
        );
        }
}