Page 1 of 1

Current Page Path ::: SOLVED :::

Posted: Tue Mar 27, 2007 11:21 am
by crankshaft
Hi;

I'm sure this is very simple, but I have serched the forums and documentation and can't seem to find the anser.

I need to create a hyperlink to the current page, and I don't want to have to hard code the page name, I guess what I need is the current page path.

I thought that a breadcrumb may do it, but it does not give me the full path.

What I need is Bookmark 1

assuming the current page to be index.php in the root folder:

index.php#bkmark1

Any ideas ??

Cheers

Re: Current Page Path

Posted: Tue Mar 27, 2007 11:25 am
by RonnyK
In the tag for "TellaFriend", is logic to pull the currentpage. There might be simpler/better methods, but that's one I've recently seen and changed (For my site I didn't want the current page, but the referring page indeed)

http://dev.cmsmadesimple.org/projects/tellafriend

Ronny

EDIT:
this post might give it faster.

http://forum.cmsmadesimple.org/index.ph ... l#msg47062

Re: Current Page Path

Posted: Tue Mar 27, 2007 11:37 am
by crankshaft
Hey Ronny;

Thanks, I just tried that and unfortunately it does not return the page, but only as far as the cms root

i.e. it returns: www.mysite.com/cms

what I was looking for is www.mysite.com/cms?page=home

I thought there may be a pre-defined tag, but obviously not ?!

Re: Current Page Path

Posted: Tue Mar 27, 2007 11:57 am
by cyberman
crankshaft wrote: What I need is Bookmark 1
A little bit ugly, but it works

Code: Select all

<a href="{root_url}/cms{$SCRIPT_NAME}?page={$page_alias}#bkmark1">Bookmark 1</a>

Re: Current Page Path ::: SOLVED :::

Posted: Tue Mar 27, 2007 12:01 pm
by crankshaft
Hi;

Thanks, but I have a solution:

create a UDT names getpageurl and add the following:

echo $_SERVER["PHP_SELF"] . ($_SERVER["QUERY_STRING"] != '' ? '?' .
$_SERVER["QUERY_STRING"] : '');

add the tag in your page:

this page

And that's it !!

Re: Current Page Path

Posted: Tue Mar 27, 2007 12:05 pm
by kermit
i chopped up some code from somewhere else awhile ago and came up with {whatsthispage}


$pageURL = "http";
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= "www.".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
  $pageURL .= "www.".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
echo $pageURL;
return;

(edit or remove "www.". as needed. did it this way to force "www." on the output even if a page is requested without it)

Re: Current Page Path ::: SOLVED :::

Posted: Tue Mar 27, 2007 12:30 pm
by crankshaft
Thanx Kermit, but I solved it with this:

echo $_SERVER["PHP_SELF"] . ($_SERVER["QUERY_STRING"] != '' ? '?' .
$_SERVER["QUERY_STRING"] : '');

Cheers

Re: Current Page Path ::: SOLVED :::

Posted: Tue Mar 27, 2007 12:34 pm
by RonnyK
REQUEST_URI would do the trick as well, as it is relative to the current root-path.

Ronny