current page 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
Locked
admsh
Forum Members
Forum Members
Posts: 93
Joined: Tue Aug 19, 2008 6:30 pm
Location: NY

current page URL

Post 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?
User avatar
aln_cms
Forum Members
Forum Members
Posts: 88
Joined: Mon Jan 08, 2007 7:09 pm
Location: Ireland

Re: current page URL

Post 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.
--
Alan Ryan
Lead Developer
CodeCrunchers Internet Software Development - Ireland
http://www.codecrunchers.ie
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: current page URL

Post 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
NaN

Re: current page URL

Post 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.
buffalokill
New Member
New Member
Posts: 5
Joined: Wed May 21, 2008 6:02 pm
Location: Backwoods, Idaho

Re: current page URL

Post 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.
JeremyBASS

Re: current page URL

Post 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
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: current page URL

Post by tyman00 »

There is also:  {$cgsimple->self_url($assign)}  in the CGSimpleSmarty module.
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
NaN

Re: current page URL

Post by NaN »

There are so many ways.
What about this:

Code: Select all


{$content_obj->GetURL()}

?
Stringfellow
Forum Members
Forum Members
Posts: 26
Joined: Wed Mar 29, 2006 4:08 pm

Re: current page URL

Post 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.
Locked

Return to “Developers Discussion”