[TYPO3] How to get domain name thru typoscript

Christopher Torgalson bedlamhotel at gmail.com
Wed Dec 26 10:25:49 CET 2007


Hi,

Elijah wrote:
> Hi,
> 
> I'm just trying to get a domain name :
> 
> lib.currentdomain = TEXT
> lib.currentdomain {
> data = DB : sys_domain : {GPvar:pid} : domainName
> data.wrap3 = {|}
> data.insertData = 1
> }
> 
> 
> I followed that snippet somewhere from this list but it doesn't work, it 
> will only work when I replace {GPvar:pid} with the correct pid number 
> from a domain record.


The question is 'what do you expect GPvar:pid to return (and why?)' The 
'GP' part of 'GPvar' stands for GET/POST, so for your TS to work there'd 
need to be a parameter in the url or in the POST array (unlikely if you 
didnt' get to the current page by submitting a form) called 'pid'. If 
neither of these is present, GPvar:pid--and therefore the entire TS 
snippet--will not return anything.

Besides all that, even if there was a 'pid' parameter in the url or in 
the POST array, it would have to somehow correspond to the uid of the 
domain record for the current domain (which is also unlikely unless 
you've set your site up that way deliberately).

If you're just trying to get the current domain name for any given page, 
something like this works ok:

lib.currentdomain = TEXT
lib.currentdomain {
	data = getEnv:HTTP_HOST
}


-- 
Christopher Torgalson / bedlamhotel at gmail.com


More information about the TYPO3-english mailing list