Page URL tag to show complete url

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
chaszu
New Member
New Member
Posts: 5
Joined: Fri Apr 03, 2009 10:12 am

Page URL tag to show complete url

Post by chaszu »

Hi All,

I'm trying to use this tag:

global $gCms;
  $hm =& $gCms->GetHierarchyManager();
  $curnode =& $hm->getNodeById($gCms->variables["page_id"]);
  $curcontent =& $curnode->GetContent();
  echo 'Page URL: ' . $curcontent->GetURL();

in the page template, and it gives me:

Page URL: http://DOMAIN.COM/index.php/page-alias

But the REAL URL of that page is:

Page URL: http://DOMAIN.COM/index.php?mact=_page- ... eturnid=56 .....

So How can I retrive the COMPLETE URL that I actually see in the browser url bar?

Thanks!
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: Page URL tag to show complete url

Post by Ted »

There's a pretty standard php recipe for that:

Code: Select all

$uri = 'http'. ($_SERVER['HTTPS'] ? 's' : '') .'://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
geepers
Dev Team Member
Dev Team Member
Posts: 84
Joined: Thu Nov 22, 2007 10:41 pm
Location: Canada

[solved] Re: Page URL tag to show complete url

Post by geepers »

Code: Select all

$uri = 'http'. ($_SERVER['HTTPS'] ? 's' : '') .'://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
is there a simple way to get the $uri variable available within an existing module? and how would you go about doing that?

i want to be able to use the above $uri value in a comparison string within a modules template.

UPDATE
Used smarty to retrieve what I needed.

Code: Select all

{$smarty.get.page}
This returned everything that would normally follow '?page=' - even returns the correct value when using friendly url's and mod_rewrite.
Last edited by geepers on Fri Jun 05, 2009 4:48 pm, edited 1 time in total.
Post Reply

Return to “Developers Discussion”