[pmwiki-users] variable returns domain name?

Patrick R. Michaud pmichaud at pobox.com
Fri Apr 13 08:07:23 CDT 2007


On Fri, Apr 13, 2007 at 07:33:44AM -0500, Tegan Dowling wrote:
> Hi, List:
> 
> I've looked through http://www.pmwiki.org/wiki/PmWiki/PathVariables
> and other pages listed on http://www.pmwiki.org/wiki/PmWiki/Variables,
> but if what I want is there, I didn't recognize it (and so apologize).
>  I'm looking for a variable that will provide my site's domain name,
> stripped of the URL's "http://www.", so, for instance, on the PmWiki
> site, it would return simply pmwiki.org.
> 
> 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." .

I much prefer this to the {(substr {$ScriptUrl} ...)} 
approach, if only because {$SiteDomain} is definitely much
more descriptive.

Pm



More information about the pmwiki-users mailing list