insert an anchor in a php link?

goldschmidt.a - May 7, 2008 - 02:55

Hi all,

This may be more of a php question than a Drupal question, but I know lots of Drupal-ers know lots of php.

I'd like to create a link in a block using php that references the current users ID number. I've been able to do that:

<?php
global $user;
echo
'
'
.l('edit my account', "user/$user->uid/edit", array('title' => 'edit my account')).'
'
;
?>

Here's the problem:
I've created an anchor on that page (using <a name="edit_picture">).

In standard html code, it's no problem to just write <a href="www.example.com/example#edit_picture">; however, I don't know how to do that in a php link. When I put the pound sign or hash (# or even the special html character #), I get the wrong URL.
Basically, I want to create a link in a block that goes to www.example.com/user/1/edit#edit_picture, where 1 is whatever number the current user is. Any ideas?

I'm using Drupal 6.

Thanks,
Andrew G

After some research, I found

goldschmidt.a - May 7, 2008 - 15:28

After some research, I found this message thread: www.drupal.org/node/81447

I'm still not getting it to work with any of those functions for Drupal 6 though. Anyone out there had any success with this in Drupal 6? Just want to replace my # (hash) correctly in php link (keeps coming up with %23 or %2523). Is the url() function better at this than the l() function prehaps?

Thanks,
Andrew G

 
 

Drupal is a registered trademark of Dries Buytaert.