[pmwiki-users] variable returns domain name?

Kathryn Andersen kat_lists at katspace.homelinux.org
Sat Apr 14 18:47:13 CDT 2007


On Sat, Apr 14, 2007 at 02:38:42PM +0200, christian.ridderstrom at gmail.com wrote:
> On Fri, 13 Apr 2007, Patrick R. Michaud wrote:
> 
> >>Is there such a animal, and if not is it possible to create a custom 
> >>one?
> >
> >$FmtPV['$SiteDomain'] =
> > "'" . preg_replace('!^\\w+://(www\.)?!', '', \$ScriptUrl) . "'";
> >
> >After this you can use {$SiteDomain} to get the site's domain name 
> >stripped of any leading "www." .
> 
> Just a comment that the above does not work if you've set $ScriptUrl to 
> e.g. '/'.  (Or have we said that $ScritpUrl is always a full/complete 
> URI?)

Mind you, if one is making a page-variable, then one doesn't need to use
$ScriptUrl to construct it, one can use the PHP variables that were used
to construct $ScriptUrl in the first place.

$FmtPV['$SiteDomain'] =
 "'" . preg_replace('!^\\w+://(www\.)?!', '', \$_SERVER['HTTP_HOST']) . "'";

(note: the above is untested)

Kathryn Andersen
-- 
 _--_|\     | Kathryn Andersen	<http://www.katspace.com>
/      \    | 
\_.--.*/    | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
      v     | 
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha!  |	-> Earth -> Sol -> Milky Way Galaxy -> Universe



More information about the pmwiki-users mailing list