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

Pages Setup Help

Discussion in 'XenForo Development Discussions' started by Cory_, Apr 19, 2012.

  1. Cory_

    Cory_ Member


    I'm trying to create a PHP Page using the PHP Callback feature, I've been in the forums and watched the videos and doesn't really work, unless I'm doing something wrong.

    This is what I'm looking for.

    I have a specific page I need created and where would I store these php files?

    2nd was is a example script for a Page Callback?

    I already have the code I'm going to embed, just trying to get and understanding on how to implement all this.

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. Cory_

    Cory_ Member

    Doesn't help as I mentioned, "watched the videos" - I have the code, but doesn't work.

    Code from:


    Doesn't tell you where to upload the files at as I'm getting the error:

    The following error occurred:
    Please enter a valid callback method.
    I've named the php file "TemplateDemo.php" like the one in the demo.

    I placed in a TemplateDemo folder and uploaded it too library/ Folder.

    I'm assuming it's in the wrong place.

    I'm using the the demo code from that page, so I'm pointed in the right direction so I can simply implement my code.

    class Dev_PageCallback_TemplateDemo
        public static function 
    respond(XenForo_ControllerPublic_Abstract $controllerXenForo_ControllerResponse_Abstract $response)
    $visitor XenForo_Visitor::getInstance()->toArray();
    $sessionModel $controller->getModelFromCache('XenForo_Model_Session');
    $response->params['onlineUsers'] = $sessionModel->getSessionActivityQuickList(
    'cutOff' => array('>'$sessionModel->getOnlineStatusTimeout())),
    $visitor['user_id'] ? $visitor null)
    // fetch recent registrations
    $userModel $controller->getModelFromCache('XenForo_Model_User');
    $response->params['users'] = $userModel->getLatestUsers(array(), array('limit' => 5));
    // fetch most recent posts
    $response->params['posts'] = self::_getPostModel($controller)->getMostRecentPosts(5$visitor);
    $response->templateName 'template_demo';
        * @return Dev_Model_Post
    protected static function _getPostModel(XenForo_ControllerPublic_Abstract $controller)
  4. Lawrence

    Lawrence Well-Known Member

    According to your class, the TemplateDemo.php file should be located here: library/Dev/PageCallback/

    Be sure the directory and file names matches exactly to the class name, ie: /dev/ will not work, it needs to be /Dev/

    I'm not sure if having a function named 'respond' will cause an issue, but I always use a function name that matches what the page is about. ie: public static function displayUserData

    Based on your code above, your page's php callback should be: Dev_PageCallback_TemplateDemo::respond

Share This Page