Pages Setup Help

Cory_

Member
Hello,

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.

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

Code from:

http://xenforo.com/community/threads/code-from-have-you-seen-videos.7236/

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

Code:
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.

PHP:
<?php
 
class Dev_PageCallback_TemplateDemo
{
    public static function respond(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract $response)
    {
        $visitor = XenForo_Visitor::getInstance()->toArray();
 
        $sessionModel = $controller->getModelFromCache('XenForo_Model_Session');
 
        $response->params['onlineUsers'] = $sessionModel->getSessionActivityQuickList(
            $visitor,
            array('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)
    {
        return $controller->getModelFromCache('Dev_Model_Post');
    }
}
 
?>

Regards,
Cory
 
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
 
Top Bottom