Hi,
I have a client that has 3 domains. he want’s to have the same content on all 3 sites and change the logo, title trail and meta description for the 3 different domains.
I would like to define global vars, that get triggered on each domain.
In the index.php I would like the following variable
$assign_to_config['global_vars'] = array(
'domain' => 'bpt'
); // This array must be associativeI know I could use something like
${_SERVER['HTTP_HOST']}to destinguish between the different domains. I just don’t know if such a thing is possible within the index.php file.
am I on the right path? any help appreciated!
cheers stefan
Hey Stefan,
Are you using MSM to handle the sites, or just different index.php files? In either case… why not just hard code the domain variable in the site specific index file? I mean- I think the server variable would work fine too, I’m just not understanding the need.
And then you’re thinking use it in either conditionals or as a variable prefix to switch out the logo/css/variable type thing? I’d think either approach would work for that. With MSM, you don’t really need it. Without it, you would.
Hey Stefan, Are you using MSM to handle the sites, or just different index.php files? In either case… why not just hard code the domain variable in the site specific index file? I mean- I think the server variable would work fine too, I’m just not understanding the need. And then you’re thinking use it in either conditionals or as a variable prefix to switch out the logo/css/variable type thing? I’d think either approach would work for that. With MSM, you don’t really need it. Without it, you would.
Hi robin,
no I am using one index file to drive 3 sites. they all point to the same public_html.
something like this works (I tested after posting this):
$assign_to_config['global_vars'] = array(
"domain" => "${_SERVER['HTTP_HOST']} "
); // This array must be associativeand then in the template I can use:
{if "{domain}" == "www.bpt.com"}...{/if}but I would like something different where I could assign more variables per site…
something like this:
<?php if (${_SERVER['HTTP_HOST']} = "www.bpt.com") {
$assign_to_config['global_vars'] = array(
"domain" => "bpt",
"language" => "en"
);}?>but I’m too bad in php to sort it all out… eventually I will get there… eventually 😛 cheers stefan
so I got it working:
if ("${_SERVER['HTTP_HOST']}" == "www.vka.com")
{
$assign_to_config['site_url'] = 'http://www.vka.com/';
$assign_to_config['global_vars'] = array(
"cgv_domain" => "vka"
); // This array must be associative
}
elseif ("${_SERVER['HTTP_HOST']}" == "www.smtr.com")
{
$assign_to_config['site_url'] = 'http://www.smtr.com/';
$assign_to_config['global_vars'] = array(
"cgv_domain" => "smtr"
); // This array must be associative
}
else
{
$assign_to_config['site_url'] = 'http://www.bpt.com/';
$assign_to_config['global_vars'] = array(
"cgv_domain" => "bpt"
); // This array must be associative
}then in my templates I can use global variables this way:
{gv_meta_descrption_{cgv_domain}}it all works quite well.
just a question: how big is this on performance? are there alternative ways to achieve this?
could you maybe transfer this thread to the code sharer forums? cheers stefan
no I am using one index file to drive 3 sites. they all point to the same public_html.
Aha- ignore me. I was totally not understanding. And yes- this should work just fine. It reminds me of what I’ve seen in configs where they’re using version control and one config across multiple environments - see example and here and basically searching for ee and version control.
Which- is not the same thing, but some of the logic of switching out based on server variables is.
But yes- what you have? Seems a totally reasonable way to do it and I wouldn’t think there’s be a performance hit from it. Can’t see why there would be.
Also- moving! Looks good, Stefan.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.