Hi, all.
I have a quick question for anyone that can help:
I came across the l() function the other day, and came to realize I should be using it in my code to generate my links.
I wrote the following link before I found this function:
<a href="/'.$_SERVER["REQUEST_URI"].'&CompletedID='.$row->TaskID . '><img src="/misc/img/b_drop.png" Title="Mark Complete" name="CompletedID" border=0></a>
Its basically an image that you click on to mark a "task" complete. It calls the current page, with a CompletedID attribute in the URL.
How to I get the path for my current page in order to use this function?
This doesn't work:
l('Image Here', $_SERVER["REQUEST_URI"], array(), "CompletedID=$row->TaskID")
This does work (but its a hack & wont work if clean URLs is on):
l('Image Here', $_GET["q"], array(), "CompletedID=$row->TaskID")
Any help would be appreciated.
Thanks,
-Ben
Comments
should work...
That looks like it should work to me.
What does it get wrong? What does the resulting link look like?
.dan.
http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
drupal_get_destination()
drupal_get_destination() returns the current path if you call it without parameters. It uses:
$destination[] = $_GET['q'];
demolicious | leafish
Thanks...
I was under the impresion that with clean url's on the 'q' attribute is gone from the URL.
i.e.
www.example.com/?q=MyPath/here
would be:
www.example.com/MyPath/here
would of thought that that meant that using $_GET['q'] would return null, since there is now no q variable in the URL?
I don't have clean URLs on (and can't turn them right now to test it). I'm gonna assume this solution works, since it is in the drupal core. Anyone know for sure? If so, how does it work?
Thanks so much for the help.
The q is hidden, but not gone
clean_urls hides the 'q' but Drupal still uses it internally.
Technically, Apache mod_rewrite accepts the clean version, then inserts the ?q= before passing the request to Drupal.
As far as PHP is concerned, it's there in the $_GET all along.
.dan.
http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thank you !
I've been searching for over an hour all over Drupal core modules ! Thank you !
Multi language friendly current path
$_GET["q"]
may not work for multi-language website , the following code will work in multi-language environmentSurprised there isn't a
Surprised there isn't a global for this
Four Kitchens | We make content go.
request_uri()
http://drupal.org/node/336154