getting $_GET variables in xenforo

Hi,

Not sure what you are trying to achieve, but you should look into routes stuff
Jaxel made a great tutorials on this subject.

But as I said, this really depends of what you try to achieve.

Clément
 
Hi,

Not sure what you are trying to achieve, but you should look into routes stuff
Jaxel made a great tutorials on this subject.

But as I said, this really depends of what you try to achieve.

Clément
i am building a webstats system for a game. a person can seached for other players and display the users stats.. i need to grab the search input params to return the correct user object
 
Then if you are doing a custom file, you need to create the adequate routes.

Anyways, if you have a functionning route, you'd have to use the filterSingle function on the input var ($this->input->filterSingle(....) if you are in a controller) function.

Look in xF files you'll see how it's done.

Clément
 
Ok I guess this is just really confusing for me. Can you help me get this setup? I can share pastes of whatever relavant code necessary just let me know what to share
 
I know how to create callback functions etc.. i just asked how to pass $_get variables into the functions and how that works. Directing me to 'tutorials' isnt really helping since I could have found them on my own. I was asking if ANYONE would be kind enough to help me understand how to do it rather than just doing the simple and pointing me to a tutorials section that isnt even specific.
 
I might not have understand your request.

What do you call a callback function ? An action ?

Or a callback called from templates ?
 
I have a custom page node that is setup with a php callback that just displays a massive table of data... i want to ADD a search form to the page in which when submitted, submit the function with the $_GET variable so it will return stats for that specific player they searched for.. i mean its super simple with php ive done it a hundreds times.. example here: http://maplecraftmc.com/player.php?player_id=32 its just this xenforo crap throws me for a loop every time..
 
Oh ok, post your current code so that we can analyse what you might be doing wrong.

That would help.
 
there's nothing wrong.. the personal stats page doesnt even exist yet.. I just know there are technically 2 ways to pass php to a page right? the php callback page on the page node, and then you can call php functions within template which I have played with a bit.. I just dont know how to actually pass $_get parameters into those functions! Also, can you explain the difference of setting of your page via the php callback tab in the pagenode settings or just using a template and calling php functions with like: <xen:callback class="HomePage_Status_Callback" method="getIP"></xen:callback>
 
It's still unclear what you exactly try to achieve.

If you have a custom page, then you can add the form to your code ?
Or are you trying to do the form retrieval once posted ?
 
lol jesus. what is unclear about 'i want to pass $_get parameters into a php function with xenforo...' that to me, is as descriptive as it gets.

edit: Im trying to submit the form to a different page which will load a function using the damn $_GET parameters lol.. its not complicated i jsut dont know how to do it in xenforo
 
What is unclear is how you call that function.

If your function is a php callback you set when creating the custom page node, you have access to all page controller variables (see XenForo_ControllerPublic_Page actionIndex()).
PHP:
call_user_func_array(array($page['callback_class'], $page['callback_method']), array($this, &$response));

Then as you have access to $this (the controller), you can use the input filter to retrieve the stuff which is in your $_GET, either using filterSingle (STRING being one of the possible types for XenForo_Input) :
PHP:
$this->_input->filterSingle('some_variable_name', XenForo_Input::STRING);
or the array method :
PHP:
          $inputData = $this->_input->filter(array(
                        "first_name"        => XenForo_Input::STRING,
                        "last_name"         => XenForo_Input::STRING,
                        "phone"             => XenForo_Input::STRING,
                        "address"           => XenForo_Input::STRING,
                        "additional_info"   => XenForo_Input::STRING
                    ));
 
I dont do any of that.. This is like beyond me id say.. ill show you what i have

PHP:
<?php
class Leaderboards_GlobalList_Callback
{
    private static $leaders = Array();
    private static $output;
   
    private static function get_GlobalList()
    {
        $global_list = new Leaderboards_GlobalList_Query();
        self::$leaders = $global_list->get_GlobalList();
        unset($global_list);
    }

    private static function format_GlobalList()
    {
        self::$output = "";
        if(is_array(self::$leaders) && count(self::$leaders) > 0)   
        {
            foreach (self::$leaders as $leader) 
            {
                self::$output .= '<tr>';   
                self::$output .= '<td width="150">' . $leader['name'] . '</td>';
                self::$output .= '<td width="70">' . $leader['pvp_kills'] . '</td>';
                self::$output .= '<td width="70">' . $leader['pvp_deaths'] . '</td>';
                self::$output .= '<td width="70">' . $leader['current_streak'] . '</td>';
                self::$output .= '<td width="70">' . $leader['max_streak'] . '</td>';
                self::$output .= '</tr>';
            }
        }
        else
        {
            // if some reason the query didn't work output a message to user
            self::$output = "<li> No members found </li>";
        }
        self::$output = '<table id="stats_table"><tr><th>Name</th><th>Kills</th><th>Deaths</th><th>Current Streak</th><th>Best Streak</th></tr>' . self::$output . '</table>';
    }
   
    /**
    * Get the Members by user groups and return the values back to the template
    * @param XenForo_ControllerPublic_Abstract $controller
    * @param XenForo_ControllerResponse_Abstract $response
    */
    public static function respond(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
    {
        self::get_GlobalList();
        self::format_GlobalList();
        $response->templateName = "test";        //name of the template to use
        $response->params['output'] = self::$output;        //html text to insert into the template
    }
}
?>
 
So you don't use Node page PHP callback ? But callback inside templates ? (if I know get you from few posts ago)

If so I am not sure that you have access to input stuff.
Or perhaps by creating an instance of xF input handler, but I am not sure, that goes beyond what I know on xF.

I would personnally have gone the Node page PHP callback way.
 
I use the node php Callback for this page. This is the callback class that I inserted into the php node callback tab. Basically I just need to pass parameters into the creation of this class object so I can query the database for the searched player. If that makes any more sense I hope
 
Oh damn yes... I am stupid...

You can get the info in the respond function.

This should work, with some_variable_name the name of the url token you are trying to retrieve :
PHP:
$yourVarRetrieved = $controller->_input->filterSingle('some_variable_name', XenForo_Input::STRING);
 
Top Bottom