OKay, this has been pissing me off for a while (excuse my french)

look at this:

This is the home page.
<p>
here is a 
<?php
global $user;
if ($user->uid) {
        print "\t    <a href=\"$PHP_SELF&nbsp;#myDiv > *\"  rel=\"lightmodal[|height:100px;width:150px]\">";
        print "user login</a>.\n";
}
else {
  print t('<a href="user/login/lightbox2" rel="lightmodal[|width:300px; height:200px;]">user login</a>');
} ?>

I am having major problems with the "$PHP_SELF" area. Assuming at all times the user is logged in, then the link "user login" points to
"http://localhost/mcc/node/ #myDiv > * ".
Only the page that I am on (which it is suppose to point to) is "http://localhost/mcc/node/1". Notice the missing "1"?

I want the link to point to "http://localhost/mcc/node/1 #myDiv > *" but the only way I can get the "1" to appear there is by putting a ? or a # immediately after $PHP_SELF, like so:

        print "\t    <a href=\"$PHP_SELF?&nbsp;#myDiv > *\"  rel=\"lightmodal[|height:100px;width:150px]\">";

only of course that one points to "http://localhost/mcc/node/1? #myDiv > *". similarly, if i put a # instead of ? then the link points to "http://localhost/mcc/node/1# #myDiv > *".
Now of course I don't want the ? or # there. But if I remove them then the 1 dissapears as well. what gives?

Comments

ajlowndes’s picture

groan...

so even if someone did give me a character that seperates $PHP_SELF from the & immediately following it without actually being shown itself, it seems that what I was trying to achieve doesn't actually work anyway. If I go into firebug then the link has href=" # myDiv > *" instead of the full path, which is what I want.
I was expecting $PHP_SELF to work the same as javascripts document.URL. Apparently it doesn't.

so does anyone have any idea how to embed all of this:

<script type=text/javascript>
document.write('<a href="' + document.URL + " #myDiv > *" + '" rel="lightmodal[|height:100px;width:150px]">"user login"</a>');
</script>

inside my php print command?

by the way for anyone wondering why i don't just change it to "user logout", the reason is that actually this will all end up as a "hidden" link inside part of a picture, so I am trying to simulate the picture not changing.