I am building a portal which will have different cities content..
When someone comes to the website i want them to choose the city and then proceed
to
or
can this be done using a single database and installation of cakephp ?
I am building a portal which will have different cities content..
When someone comes to the website i want them to choose the city and then proceed
to
or
can this be done using a single database and installation of cakephp ?
Yes it's possible.
Basically in your DNS you have to allow *.site.com to be hosted on a single machine. This way, no matter what subdomain you type the machine will be the same.
an example dns record:
* A 10.0.0.1
Then in the virtual host declaration you have to put
<VirtualHost *>
DocumentRoot /var/www/path_to_site
ServerName site.com
ServerAlias www.site.com *.site.com
</VirtualHost>
this way no matter what you type i.e. something.site.com or city.site.com will be redirected to a single app.
Then you have just to parse the host from the php (preferably in AppController) and to transform the subdomain to filter.
It's a little bit abstract, but that's how I would do it.
Edit (response to the comment): It's a matter of how it is build the system. Basically if yo have:
cite1.site.com
in your AppController you can have something like:
class AppController extends Controller {
function beforeFilter(){
$host = explode('.', $_SERVER["HTTP_HOST"]);
$subdomain = $host[0];
Configure::write('city', $subdomain);
$this->City->getId($subdomain); //function in City model fetching City ID by city name
...
}
}
So basically, after this it depends what is your application architecture and how you deal with this city.