Page 1 of 1

current page URL

Posted: Sat Sep 13, 2008 3:37 pm
by admsh
i want to add social-bookmarks to my news section. to do that i need to be able to bring up the current page URL and title. title i can do, but hwo do i show the current page URL?

Re: current page URL

Posted: Mon Sep 29, 2008 2:23 pm
by aln_cms
use the PHP variable 

Code: Select all

$_SERVER['PHP_SELF'] 
( http://ie2.php.net/reserved.variables.server ), you'll have to modify config.php to allow use of php in the template.

Re: current page URL

Posted: Mon Sep 29, 2008 3:10 pm
by blast2007
aln_cms wrote: use the PHP variable 

Code: Select all

$_SERVER['PHP_SELF'] 
( http://ie2.php.net/reserved.variables.server ), you'll have to modify config.php to allow use of php in the template.
Or create a new UDT php_self:

echo $_SERVER['PHP_SELF'] ;

regards
blast

Re: current page URL

Posted: Mon Sep 29, 2008 5:14 pm
by NaN
It also should be within the smarty variable $nodelist.
Use the plugin {get_template_vars} to see what vars are available in your template.
If the $nodelist is there use {$nodelist|print_r} to see what else varaibles are in that $nodelist.
With a foreach-loop you can filter all entries in that list:

Code: Select all


{foreach from=$nodelist item=node}
{if $node->id==$content_id}{$node->url}{/if}
{/foreach}

If you are using several menus be sure to call that code above before the other menu is called because the next menu will override the $nodelist with the items that are in that menu.
Therefore you will not find the current menus url node.

Re: current page URL

Posted: Tue Apr 20, 2010 5:45 pm
by buffalokill
For folks like me who find this thread and are asking the same questions... I found this solution to be the one that worked.

I have the mod_rewrite for pretty urls and hierarchy switched on. I set up a UDT using this

Code: Select all

echo $_SERVER['REQUEST_URI'];
  and I named it pageurl

so when I use  {pageurl} in my template, it spit out http://mydomain.com/category-name/product-name.php

Hope that helps.

Re: current page URL

Posted: Tue Apr 20, 2010 7:46 pm
by JeremyBASS
if you need a really url of your location.. something like this is what you want..

UDT- RealURL

Code: Select all

global $gCms;
$urlBASE = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
if (!empty($_SERVER["QUERY_STRING"]))
$urlBASE .= "?".$_SERVER['QUERY_STRING'];
if (isset($gCms->config['assume_mod_rewrite']) && ($gCms->config['assume_mod_rewrite']==true)) {
 
$urls = str_replace("index.php?page=", "", $urlBASE);
$urls = str_replace("index.php", "", $urls);
 
}else{
 
$urls = $urlBASE;
 
}
echo $urls;

so what this does is give you pURL of the module your in ie products or what not.. sometime you just can use the geturl provided by CMSMS, or by simple using the $_SERVER['REQUEST_URI']; .. just thought I'd point that out.. hope this helps..

Cheers -Jeremy

Re: current page URL

Posted: Thu Apr 22, 2010 8:50 pm
by tyman00
There is also:  {$cgsimple->self_url($assign)}  in the CGSimpleSmarty module.

Re: current page URL

Posted: Fri Apr 23, 2010 12:57 am
by NaN
There are so many ways.
What about this:

Code: Select all


{$content_obj->GetURL()}

?

Re: current page URL

Posted: Mon Jan 23, 2012 5:41 am
by Stringfellow
buffalokill wrote:For folks like me who find this thread and are asking the same questions... I found this solution to be the one that worked.

I have the mod_rewrite for pretty urls and hierarchy switched on. I set up a UDT using this

Code: Select all

echo $_SERVER['REQUEST_URI'];
  and I named it pageurl

so when I use  {pageurl} in my template, it spit out http://mydomain.com/category-name/product-name.php

Hope that helps.
Perfect! This is the correct solution! Thank you!

I used this in facebook comments-system when the facebook-plugin wants the current href.