XF 2.0 $this->filter('state', 'str')

AndrewSimm

Well-known member
I am working on a using #_GET to filter data.. Let's say the visit the page "index.php?players/" and don't filter yet. How would I assign the variable to have the "all" value? The code bellow is not working.

PHP:
$get_state = $this->filter('state', 'str');

if(!isset($get_state) OR $get_state == "all" OR $get_state = "") {
    $get_state = "all";
    $state_op = "!=";
} else {
    $state_op = "=";
}
 
index.php?players/&state=all

with the link helper:

{{ link('players', '', { "state": "all" }) }}


Never mind, I see what you mean. You have $get_state = "" in your conditional is this intentional?
 
index.php?players/&state=all

with the link helper:

{{ link('players', '', { "state": "all" }) }}

Is that going to set the default if the visit the link and it's empty? I don't have a problem with it working when I click the filter.

Code:
index.php?class=all&position=all&state=all&rating=all&status=all&_xfRoute=players%2F

Basically I want the default value to be "all" unless they are set.
 
PHP:
$get_state = $this->filter('state', 'str');

if ($get_state == 'all' OR $get_state == '')
{
    $get_state = 'all';
    $state_op = '!=';
}
else
{
    $state_op = '=';
}
 
PHP:
$get_state = $this->filter('state', 'str');

if ($get_state == 'all' OR $get_state == '')
{
    $get_state = 'all';
    $state_op = '!=';
}
else
{
    $state_op = '=';
}

I tried this and still nothing. When I dump $get_state nothing is there.

edit: Just kidding, I had typos :)
 
Back
Top Bottom