Welcome Guest, Not a member yet? Register   Sign In
$_GET + Nice URLs ??!??
#1

[eluser]llbbl[/eluser]
So there is no way to have the best of both worlds is there?

I know about uri class:
$suckage = $this->uri->segment(3,0);


But I am finding that it would also be nice to have $_GET for *some* pages. (You know example.php?irule=yea&sodoes=codeigniter)

However I don't want to turn off nice urls for the ENTIRE freaking site.
#2

[eluser]Majd Taby[/eluser]
Do you think it would be useful to write a controller which converts something like http://www.site.com/controller/function/params/foo/bar which would take the urls, look for a "params" in it, if it has it, then it treats foo and bar as $_GET['foo'] = $bar? and passes them to controller::function?

$this->uri->uri_to_assoc(n) (http://ellislab.com/codeigniter/user-gui...s/uri.html) looks promising
#3

[eluser]llbbl[/eluser]
It is not what I want to do, and I don't think it is possible, because everything is passed through index.php. I am in essentially wanting index.php/p/12323/ and index.php?p=32154 to work differently.
#4

[eluser]onejaguar[/eluser]
Stick this in a library, call as needed:
Code:
//
  // Stuff GET values into $_POST to get around
  // Code Igniter's crazy GET phobia.
  // NOTE: For this to work the app's main config must be set to:
  //   $config['uri_protocol'] = "PATH_INFO";
  //
  function getIntoPost() {
    parse_str($_SERVER['QUERY_STRING'], $_POST);
    foreach ($_POST as $key=>$val) $_POST[$key] = $this->CI->input->xss_clean($val);
  }
#5

[eluser]llbbl[/eluser]
I have been using something like this for several years now. (get/post)

Code:
foreach($_POST AS $key => $value) {
            ${$key} = mysql_real_escape_string($value);
        }

But that is not what I am looking for. Thanks for trying. Smile
#6

[eluser]llbbl[/eluser]
I believe in using php functions whenever possible, to avoid any additional hit to the CPU.
#7

[eluser]onejaguar[/eluser]
My code puts GET variables into $_POST but you could easily change it to put them into $_GET and leave out the cleaning bits. It would look like this:

Code:
function recoverGet() {
    parse_str($_SERVER['QUERY_STRING'], $_GET);
  }

This allows you to use paths for calling controller functions and use GET variables at the same time. If you alternately want to use the path or GET for calling controller functions, setting your config to:

$config[’uri_protocol’] = “AUTO”;

Should handle both.
#8

[eluser]llbbl[/eluser]
Ok I see now. Still not what I am looking for. I know I didn't explain the problem very well, sorry about wasting your time.

I have solved the problem using sessions, by setting a custom session variable with the information I needed.
#9

[eluser]mistress_shiira[/eluser]
[quote author="llbbl" date="1194591251"]Ok I see now. Still not what I am looking for. I know I didn't explain the problem very well, sorry about wasting your time.

I have solved the problem using sessions, by setting a custom session variable with the information I needed.[/quote]

can you explain more in detail how you have achieved that?cause i might be able to use that too.i have also problems in $_GET variables for some of my pages.
like i have this snippet:
Quote: <a href='editcampaign.php?CID=$campaign_ID'>$campaign_name</a>
id like to redirect it to editcampaign.php with the CID.
how is that going to be in CI?
#10

[eluser]llbbl[/eluser]
use the URI class:
http://ellislab.com/codeigniter/user-gui...s/uri.html

results in:
<a href=’editcampaign/CID/$campaign_ID’>$campaign_name</a>

You can't use GET in normal way with CI because of the MVC configuration with everything being a class passed through index.php.

editcampaign would be your class
CID would be a function within the class
using URI class you can pull the campaign_id from the url

get it now? you should really spend some time reading the user guide. Smile




Theme © iAndrew 2016 - Forum software by © MyBB