Page 1 of 1

Alternates to url arguments ($_GET)

Posted: Mon Apr 25, 2005 10:29 pm
by nickvd
I remember reading a thread, or an article about getting rid of url parameters in the standard form: page.php?foo=bar

with something like: page.php/foo/bar

However, after much searching on google, i've come up empty handed. If anyone has the page in question bookmarked, i surely could use it :)

On to the real reason why i'm doing it this way. I'm writing a quick breadcrumbs class (more heavily modifying than writing) and most of my pages use the ?page=articles&id=3 scheme... This will obviously not work, since the page is always index.php... however, using the page.php/page/articles/id/3 or even just page.php/articles/3 would let me use the bread crumbs w/o having to have an array of all pages/subpages...

Posted: Mon Apr 25, 2005 11:09 pm
by Ambush Commander
Okay, I don't exactly have the answer to your question, but I have two comments that are based on my experience:

1. This type of "Paging" isn't available to all PHP/Webserver combos, so don't count on being able to do it.

2. Because you seem to have a clearly defined hierarchy for your GET lables, why not do the necessary breadcrumb juggling yourself? First you define the list of GET values:

Code: Select all

$LIST_GET_TREEї] = 'article';
$LIST_GET_TREEї] = 'id';
The closer to zero, the closer to the root of the tree, so to speak. You can do some things, like:

Code: Select all

$tree_size = size();
for($i = 0; $i < $tree_size; $i++) {
  // clean() is a user defined func that you use to filter parameters, like restrict to integers or whatnot.
  if (isset($_GETї$tree_sizeї$i]]) AND clean($_GETї$tree_sizeї$i]], $tree_sizeї$i])) {
    break;
  } else {
    $LIST_PARAMETERSї] = $_GETї$tree_sizeї$i]]
  }
}
I'm interested. What premade class are you using for breadcrumbing?

Posted: Tue Apr 26, 2005 2:09 am
by timvw
the keywords needed for a websearch is "url rewriting" and then everything becomes clear :)

Posted: Tue Apr 26, 2005 12:21 pm
by vigge89

Code: Select all

$args = explode ('/', $_SERVER['PATH_INFO']);
$args will then contain the splitted arguments (what I call them :P )

http://se.php.net/manual/en/reserved.va ... les.server