prowebinteractiveinc
asked on
header in php for more the one website
I have 2 websites, basically the same thing except the language is different. I know I could do this all on one domain, but I want to have an english and a french domain name for certain reasons, both with have the same code obviously. Im working roght now in the header which basically is the main navigation.
I was thinking of doing something like this - because I may want to add more domains later
$currentDomainName = $_SERVER['SERVER_NAME'];
$myDomains = array("domainEng.com", "domainFr.com");
while($myDomains)
{
Show navigation for domain
}
however the navigation could difer from site to site, I want to be able to chose the name of the links for each site.
I was thinking of doing something like this - because I may want to add more domains later
$currentDomainName = $_SERVER['SERVER_NAME'];
$myDomains = array("domainEng.com", "domainFr.com");
while($myDomains)
{
Show navigation for domain
}
however the navigation could difer from site to site, I want to be able to chose the name of the links for each site.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK, If I am understanding this correctly, you want to detect the name of the domain. You've got that part right in $_SERVER["SERVER_NAME"]. Then perhaps you would want a switch/case construct something like this (untested but probably valid in principle). It will provide an abstraction layer that matches the detected domain to the name of the file that contains the navigation script.
<?php // UNTESTED CODE
switch (strtolower($_SERVER["SERVER_NAME"]))
{
case "domainen.com": $inc = "english_nav.php"; break;
case "domainfr.com": $inc = "french_nav.php"; break;
default: $inc = "english_nav.php";
}
require_once($inc);
ASKER
ok, I think I get the idea, however instead of using a file for the navigation I have to arrays link names and link urls such as:
what is line 6 and line 8 for ?
$pgName = array("Accueil", "Profil", "Application de credit", "Inventaire virtuel", "Credit 101", "Contact");
$pgUrl = array("index.php", "profil.php", "application.php", "inventaire.php", "credit101.php", "contact.php");
what is line 6 and line 8 for ?
Line 6 is the default navigation if the domain does not match any case in the switch structure.
Line 8 brings into the current scope of the script, and runs the script, named in the variable $inc.
Line 8 brings into the current scope of the script, and runs the script, named in the variable $inc.
ASKER