Solved

header in php for more the one website

Posted on 2012-04-05
5
230 Views
Last Modified: 2012-08-14
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.
0
Comment
Question by:prowebinteractiveinc
  • 3
  • 2
5 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 37811686
Have a look at this article and see if the design pattern makes sense for you.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_8910-A-Polyglot-Web-Site-in-PHP.html
0
 

Author Comment

by:prowebinteractiveinc
ID: 37811832
your not understanding what i want... forget the fact that im trying to control languages. I want to control the main navigation of multiple websites, contained in one file shared upon all websites...
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37811908
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);

Open in new window

0
 

Author Comment

by:prowebinteractiveinc
ID: 37812744
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:

	$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");

Open in new window


what is line 6 and line 8 for ?
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37812873
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP_POST() error message 9 41
Mysql sync between 3-4 mysql db 4 24
unset shopping cart session 15 29
How do I put a session for a radio button? 4 12
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now