Jump to content


Photo

getting the current page full URL


  • Please log in to reply
7 replies to this topic

#1 mikef

mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 16 November 2007 - 04:57 PM

I'd like to be able to get hold of the actual url a page was obtained with (including ? parameters and any # anchor), in order to use in a snippet. Is there any way of obtaining this?

#2 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 16 November 2007 - 05:38 PM

http://www.dreaminco.../snippet104.htm
<?
$_SERVER['FULL_URL'] = 'http';
if($_SERVER['HTTPS']=='on'){$_SERVER['FULL_URL'] .=  's';}
$_SERVER['FULL_URL'] .=  '://';
if($_SERVER['SERVER_PORT']!='80') $_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
else
$_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
if($_SERVER['QUERY_STRING']>' '){$_SERVER['FULL_URL'] .=  '?'.$_SERVER['QUERY_STRING'];}
?>

return $_SERVER['FULL_URL']; will give the query string used in the browser It may have to be decoded.

Yeah I know... I'm bored.

Edited by Cris D., 16 November 2007 - 05:48 PM.


#3 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 16 November 2007 - 05:41 PM

$url = $etomite->makeUrl($etomite->documentIdentifier); should do the trick... Or you can use [(www_base_path)][*alias*][(friendly_url_suffix)] or [(www_base_path)]/index.php?id=[*id*] if you aren't using FURL's or Aliases...

#4 mikef

mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 16 November 2007 - 08:39 PM

Thanks Cris, I'll look into those later.

Ralph, your suggestions will give me what etomite thinks the url for the page ought to be, not what was actually used, complete with any query parameters or anchor specifications. The format I use for my site for the expected base url is [(www_base_path)][~[*alias*]~] which I think also caters for friendly URL prefixes (not that I use one).

Thinking about it further, what I really really want is the url before going through the .htaccess rules, but I don't think thats likely to be available.

#5 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 17 November 2007 - 03:46 PM

Thinking about it further, what I really really want is the url before going through the .htaccess rules, but I don't think thats likely to be available.

There is a way to get the entire URL that was used to call the current page... $_SERVER["HTTP_REFERER"] will give the entire URL of the referer... $_SERVER["REQUEST_URI"] can be used to get everything beyond the actual server itself, similar to /manager/index.php?a=200... This could be used with $_SERVER["HTTP_HOST"], whcih would return something like dahlgren.slyip.com...

Combining any of these with [(server_protocol)], which returns either http[/] or https gives pretty complete flexibility... I gathered thses settings by snooping around in Etomite manager > View system info > Server Information > View and [b]Etomite manager > Etomite configuration > Site settings and checking the available Etoimite system tags...

Not sure if this helps, but someone may find the information helpful...

#6 mikef

mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 17 November 2007 - 05:56 PM

Thanks Ralph. I think the three $_SERVER parts may give me what I need. time to play around ... once I've figured out how to center an image in a div (there are times I hate CSS)

#7 Dean

Dean

    Loves Etomite Forums!

  • Admin
  • 4,787 posts

Posted 17 November 2007 - 09:38 PM

The format I use for my site for the expected base url is [(www_base_path)][~[*alias*]~] which I think also caters for friendly URL prefixes (not that I use one).



Shouldn't that be [(www_base_path)][~[*id*]~] ? That'd generate the correct url depending on the configuration....

#8 mikef

mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 18 November 2007 - 12:08 AM

Shouldn't that be [(www_base_path)][~[*id*]~] ? That'd generate the correct url depending on the configuration....

probably, but I always use an alias ;)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users