Add-on Help

BigBoomer

Member
** This is my first project, and I'm new to PHP, AJAX and XenForo's language. **

I have created an add-on and am having trouble with displaying the data. I have based the file structure on Kier's tutorial here http://xenforo.com/community/threads/scratchpad-demonstration-ajax-add-on.8369/

It uses AJAX to handle a form and display data in a template include upon submission. I am using the Model class in the structure to pull data from an API, assign the JSON array to a variable and return that array. The idea then is for AJAX to display the array in the template include.

The problem is that I don't know if the data is actually being returned, or if I'm even calling it properly.

PHP:
<?php

class KixUtils_GameInfo_ControllerPublic_Index extends XenForo_ControllerPublic_Abstract
{
    public function actionIndex()
    {
        $viewParams = array('new' => true, 'empty' => false);
        return $this->responseView(
            'KixUtils_GameInfo_ViewPublic_Index',
            'gameinfo_index',
            $viewParams
        );
    }

    public function actionGameInfo()
    {
       
        $this->_assertPostOnly();

        $this->_assertRegistrationRequired();

       
        $name = $this->_input->filterSingle('name', XenForo_Input::STRING);
       
       
        if ($name != '')
        {
       
        if ($this->_noRedirect())
            {
            $infoModel = $this->_getInfoModel();
           
            $gInfo = $infoModel->getGameInfo($name);

           
            $viewParams = array(
                'alias' => $gInfo["alias"],
                'level' => $gInfo["level"],
                'locationX' => $gInfo["locationX"],
                'locationY' => $gInfo["locationY"],
                'sector' => $gInfo["sector"],
                'world' => $gInfo["world"],
                'new' => false,
                'empty' => false
                );
            }else{
                $viewParams = array('empty' => true);
            }
       
        return $this->responseView(
            'KixUtils_GameInfo_ViewPublic_Index',
            'gameinfo_index',
            $viewParams
        );
        }

        return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            XenForo_Link::buildPublicLink('kixutils')
        );
    }

    protected function _getInfoModel()
    {
        return $this->getModelFromCache('KixUtils_GameInfo_Model_Info');
    }
}
 
Top Bottom