Discussion:
[TYPO3] How to get domain name thru typoscript
Elijah
17 years ago
Permalink
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.

Has anyone done this before?



Regards,
Elijah
Christopher Torgalson
17 years ago
Permalink
Hi,
Post by Elijah
Hi,
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
Elijah
17 years ago
Permalink
Thank you for spotting my mistakes there, no wonder it isn't working.

What I was actually trying to do is to grab the domain name record for
each menu item(if there is any), the code you've given me works great
for my site but when used in a menu and a particular menu item has it's
own domain name it will still fetch the current domain.
...
Christopher Torgalson
17 years ago
Permalink
Post by Elijah
Thank you for spotting my mistakes there, no wonder it isn't working.
What I was actually trying to do is to grab the domain name record for
each menu item(if there is any), the code you've given me works great
for my site but when used in a menu and a particular menu item has it's
own domain name it will still fetch the current domain.
That's right--because menus are a special case where each menu item's
'scope' is that of the page record of the current/given page. Glad it's
working out.
--
Christopher Torgalson / bedlamhotel at gmail.com
Peter Klein
17 years ago
Permalink
Hi Elijah.
I had to do something similar a while ago, and did it using CASE.
The problem is that you can't use "select" on tables starting with "sys_" so
short of writing a userfunc, I did this:

-- cut --
lib.domain = COA
lib.domain {
10 = CASE
10.key.data = leveluid:0
10.default = TEXT
10.default.data = DB:sys_domain:2:domainName
10.52 = TEXT
10.52.data = DB:sys_domain:1:domainName
}
page.100 < lib.domain
-- cut --

It uses the rootpid "leveluid:0" to determine which domain record to fetch.

--
Peyter Klein / Umloud Untd


"Elijah" <elijah.alcantara at gmail.com> wrote in message
Post by Elijah
Hi,
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.
Has anyone done this before?
Regards,
Elijah
Elijah
17 years ago
Permalink
Hi Peter,

Thanks for the help, the code fetched my root domain but when the menu
traverses down it's submenus with subdomains it still gets the root
domain. I guess it needs id's set manually? (sorry I rarely used case) I
was hoping for something that could fetch without setting id's since
I'll be having hundreds of subdomains/domains down the tree.

Maybe a separate php script is the way to go.. but I was hoping for a
typoscript way..


Best regards,
Elijah
...
Loading...