Welcome Guest, Not a member yet? Register   Sign In
Stuck If Statment Gets Canceld
#3

(04-29-2015, 09:42 AM)CroNiX Wrote: $path = $this->input->get('path');
$page_id = $this->input->get('page_id');

Those will never return boolean "TRUE" like you are testing for. They will either be the values from the GET variable if they exist, or boolean FALSE if they don't (CI2), or NULL in CI3 if it doesn't exist.

So you'd probably want your logic to be more like:

PHP Code:
if ($path === FALSE) {
 
 //$path did not have a value in GET
 
 $route current_url();
} else {
 
 $route current_url() . '/?&path=' $path;
}

//or just use ternary operator instead of above:
$route = ($path === FALSE) ? current_url() : current_url() . '/?&path=' $path

And incorporate the same logic for your $page_id check.

Not sure why you have "?&" for your query string with nothing in between though.
Should be ?something=var1&something_else=var2

Thanks for that advice I am still learning query strings. Today I also tried code below and seem to work fine but will try and work out what the best is.


PHP Code:
$url current_url();
$path $this->input->get('path');
$page_id $this->input->get('page_id');

if (isset(
$path)) {
$route $url '/?&path=' $path;
} elseif (isset(
$page_id)) {
$route $url '/?&path=' $path '&page_id=' $page_id;
} else {
$route $url;

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
Stuck If Statment Gets Canceld - by wolfgang1983 - 04-29-2015, 06:50 AM
RE: Stuck If Statment Gets Canceld - by CroNiX - 04-29-2015, 09:42 AM
RE: Stuck If Statment Gets Canceld - by wolfgang1983 - 04-29-2015, 08:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB