Current Page Path ::: SOLVED :::

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
crankshaft
Forum Members
Forum Members
Posts: 57
Joined: Sun Mar 25, 2007 7:42 am

Current Page Path ::: SOLVED :::

Post 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
Last edited by crankshaft on Tue Mar 27, 2007 12:02 pm, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Current Page Path

Post 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
crankshaft
Forum Members
Forum Members
Posts: 57
Joined: Sun Mar 25, 2007 7:42 am

Re: Current Page Path

Post 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 ?!
cyberman

Re: Current Page Path

Post 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>
crankshaft
Forum Members
Forum Members
Posts: 57
Joined: Sun Mar 25, 2007 7:42 am

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

Post 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 !!
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Current Page Path

Post 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)
Last edited by kermit on Tue Mar 27, 2007 12:11 pm, edited 1 time in total.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
crankshaft
Forum Members
Forum Members
Posts: 57
Joined: Sun Mar 25, 2007 7:42 am

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

Post by crankshaft »

Thanx Kermit, but I solved it with this:

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

Cheers
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

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

Post by RonnyK »

REQUEST_URI would do the trick as well, as it is relative to the current root-path.

Ronny
Post Reply

Return to “Layout and Design (CSS & HTML)”