Re: [fw-general] Creating a multiple language website to use the same php scripts
Hi Szymon, Thanks so much for your detailed reply below. I have been experimenting with this but however have a complication and would really appreciate if you could help me out. To start, I have a administrator section that is to be kept separate from the public site http://123.231.21.214/zend-test/public/admin/products/ (this is just a test url that we are working on - assume that "http://123.231.21.214/zend-test/public/"; is the public domain) That works fine now. But when I edit my bootstrap.php file to use the routing functionality you mentioned, i.e. $route = new Zend_Controller_Router_Route( ':publicsitecode/:controller/:action/*', array( 'publicsitecode' => 'uk' ) ); $router->addRoute('default', $route); then my "admin" section does not work. Everything renders to the index view. So, I tried to change this by adding the following code, to keep a separate route to my "admin" section so that the AdminController is included: $router = $frontController->getRouter(); $route = new Zend_Controller_Router_Route( 'admin/:action/*', array( 'action' => 'index' ) ); $router->addRoute('default', $route); $route = new Zend_Controller_Router_Route( ':publicsitecode/:controller/:action/*', array( 'publicsitecode' => 'uk' ) ); $router->addRoute('default', $route); The above code correctly includes my AdminController. However, the view rendered is not the Admin views we were using..instead, the index view http://123.231.21.214/zend-test/public/ is displayed .. basically, the index view is included (which currently simply prints some basic text), whereas ZF should use the Admin view instead. I tried it a different way, by using a static route $route = new Zend_Controller_Router_Route_Static( 'admin', array('controller' => 'admin', 'action' => 'index') ); $router->addRoute('default', $route); or $route = new Zend_Controller_Router_Route_Static( 'admin', array('controller' => 'admin', 'action' => 'index') ); $router->addRoute('admin', $route); But neither of these solved my problem :( Before I go too deep into the rerouting for my public website, do you know: a) How I can solve the above problem? so that my "admin" url is treated separately and the controller/view are taken from ZF in the 'usual' way? b) How I can mimic an htaccess file to pass unlimited parameters, for example: www.mydomain.com/products/boots/polly/5/black/ and www.mydomain.com/products/boots/polly/5/ and www.mydomain.com/products/boots/polly/ and www.mydomain.com/products/boots/ should all be working URLs that either go to a products controller or action (I don't mind doing what is needed via a controller or action, whatever is more 'normal' in terms of ZF coding to generate the content for the products page depending on the paramters passed via url) Likewise, in the CMS part of the site, www.mydomain.com/pages/about_us/ and www.mydomain.com/pages/terms_and_conditions/ where the variable after "pages" in the URL is a special parameter that identifies the page via the database. You have said that using ZF's Zend_Controller_Router_Route will solve my problem for multiple languages (e.g. www.mydomain.com/pages/about_us/ will by default go to the English page identified by 'about_us', but www.mydomain.com/de/pages/about_us/ will load the German page identified by 'about_us') however I am not sure how to tell ZF to load the correct controller/view and give the correct parameters to that controller, just like an htaccess file does. Any suggestions or further reading you can recommend? Many thanks! Rishi --- On Fri, 6/20/08, SWilk <[EMAIL PROTECTED]> wrote: > From: SWilk <[EMAIL PROTECTED]> > Subject: Re: [fw-general] Creating a multiple language website to use the > same php scripts > To: "Rishi Daryanani" <[EMAIL PROTECTED]> > Cc: fw-general@lists.zend.com > Date: Friday, June 20, 2008, 3:00 PM > Hi, > > Rishi Daryanani wrote: > > Hi, > > > [] > > Basically we are planning to set up the English site > > under the main domain and language sites under a > > directory structure like the above, so the following > > would be valid: > > > > http://www.mydomain.com/ads/cars/36/ > > {shows content in English and uses a certain > > controller and view to do this} > > > > http://www.mydomain.com/sg/ads/cars/36/ > > (must use the same controller and view, but the site > > id will be different (stored in a session) and &g
Re: [fw-general] Creating a multiple language website to use the same php scripts
Hi Rishi, The set up you describe is perfectly possible with ZF... Have you checked out Magento? You may not want to use it per se but it is built on ZF and they use a sites/stores breakdown that is the sort of thing you're aiming at --- you could use it for inspiration at least... http://www.magentocommerce.com/wiki/ welcome_to_the_magento_user_s_guide/ chapter_1#elements_and_terminologies_of_magento_sites (Sorry I think that link might break...) Regards, Carlton On 20 Jun 2008, at 06:17, Rishi Daryanani wrote: Hi all, Sorry but since I didn't receive any replies to the below I wanted to try once more.. My biggest concern is how to share code between multiple sub- sites.. ZF actions seem really useful for this but then again, maybe I did my own PHP function to replicate what .htaccess mod_rewrite does...and go through the URL part by part to do redirects... Does anyone have any recommendations on how to tackle this, or does my solution above sound like the right thing to do? (i.e. custom php code to mimic .htaccess mod_rewrite, without making use of ZF actions) Please see my email below to get a better idea of what I'm trying to do. Thanks so much to everyone for your time. Thanks, Rishi --- On Wed, 6/11/08, Rishi Daryanani <[EMAIL PROTECTED]> wrote: From: Rishi Daryanani <[EMAIL PROTECTED]> Subject: [fw-general] Creating a multiple language website to use the same php scripts To: fw-general@lists.zend.com Date: Wednesday, June 11, 2008, 8:46 PM Hi, I am setting up a site which will be divided into subsites, one per country (for a set number of countries). The sites will be the same (the coding must be shared), but the content will vary depending on the site ID or code, for example, the following URLs should work for my site..and the key difference would be the SITE ID as you can see below (which will show different content from a database, based on that site id): http://www.mydomain.com/ {english site} http://www.mydomain.com/nl/ (netherlands site) http://www.mydomain.com/de/ (german site) http://www.mydomain.com/ads/cars/36/ http://www.mydomain.com/nl/ads/cars/36/ http://www.mydomain.com/de/ads/cars/37/ Basically we are planning to set up the English site under the main domain and language sites under a directory structure like the above, so the following would be valid: http://www.mydomain.com/ads/cars/36/ {shows content in English and uses a certain controller and view to do this} http://www.mydomain.com/sg/ads/cars/36/ (must use the same controller and view, but the site id will be different (stored in a session) and therefore display everything in the other language/country My question - how can I do this in ZF? In the IndexController, I know I can define functions for the above like this: public function adsAction() { } But then how do I make sure the same function is called if I go to a URL like this: http://www.mydomain.com/sg/ads/cars/36/ public function sgAction() { //set session site id as "sg" //redirect to adsAction() if /ads/ is the next item in the URL, or redirect to productsAction if the next item in the URL is "products", or redirect to indexAction if there is no "next" item in the URL } Can someone please let me know how to code this? I'm still a newbie... the complication comes in because the redirect depends on the URL. You may also have a URL like this: http://www.mydomain.com/?myparameter=1 http://www.mydomain.com/nl/?myparameter=1 Basically in both cases, I would want the indexAction to be called with the appropriate session siteid set, and the parameter would also need to be passed without change. Any advice on the best way to do this? Many thanks!
Re: [fw-general] Creating a multiple language website to use the same php scripts
Hi all, Sorry but since I didn't receive any replies to the below I wanted to try once more.. My biggest concern is how to share code between multiple sub-sites.. ZF actions seem really useful for this but then again, maybe I did my own PHP function to replicate what .htaccess mod_rewrite does...and go through the URL part by part to do redirects... Does anyone have any recommendations on how to tackle this, or does my solution above sound like the right thing to do? (i.e. custom php code to mimic .htaccess mod_rewrite, without making use of ZF actions) Please see my email below to get a better idea of what I'm trying to do. Thanks so much to everyone for your time. Thanks, Rishi --- On Wed, 6/11/08, Rishi Daryanani <[EMAIL PROTECTED]> wrote: > From: Rishi Daryanani <[EMAIL PROTECTED]> > Subject: [fw-general] Creating a multiple language website to use the same > php scripts > To: fw-general@lists.zend.com > Date: Wednesday, June 11, 2008, 8:46 PM > Hi, > > I am setting up a site which will be divided into > subsites, one per country (for a set number of > countries). The sites will be the same (the coding > must be shared), but the content will vary depending > on the site ID or code, for example, the following > URLs should work for my site..and the key difference > would be the SITE ID as you can see below (which will > show different content from a database, based on that > site id): > > http://www.mydomain.com/ {english site} > http://www.mydomain.com/nl/ (netherlands site) > http://www.mydomain.com/de/ (german site) > > http://www.mydomain.com/ads/cars/36/ > http://www.mydomain.com/nl/ads/cars/36/ > http://www.mydomain.com/de/ads/cars/37/ > > Basically we are planning to set up the English site > under the main domain and language sites under a > directory structure like the above, so the following > would be valid: > > http://www.mydomain.com/ads/cars/36/ > {shows content in English and uses a certain > controller and view to do this} > > http://www.mydomain.com/sg/ads/cars/36/ > (must use the same controller and view, but the site > id will be different (stored in a session) and > therefore display everything in the other > language/country > > > My question - how can I do this in ZF? In the > IndexController, I know I can define functions for the > above like this: > > public function adsAction() { > } > > But then how do I make sure the same function is > called if I go to a URL like this: > http://www.mydomain.com/sg/ads/cars/36/ > > public function sgAction() { > //set session site id as "sg" > //redirect to adsAction() if /ads/ is the next item > in the URL, or redirect to productsAction if the next > item in the URL is "products", or redirect to > indexAction if there is no "next" item in the URL > } > > Can someone please let me know how to code this? I'm > still a newbie... the complication comes in because > the redirect depends on the URL. You may also have a > URL like this: > > http://www.mydomain.com/?myparameter=1 > http://www.mydomain.com/nl/?myparameter=1 > > Basically in both cases, I would want the indexAction > to be called with the appropriate session siteid set, > and the parameter would also need to be passed without > change. > > Any advice on the best way to do this? > > Many thanks!
[fw-general] Creating a multiple language website to use the same php scripts
Hi, I am setting up a site which will be divided into subsites, one per country (for a set number of countries). The sites will be the same (the coding must be shared), but the content will vary depending on the site ID or code, for example, the following URLs should work for my site..and the key difference would be the SITE ID as you can see below (which will show different content from a database, based on that site id): http://www.mydomain.com/ {english site} http://www.mydomain.com/nl/ (netherlands site) http://www.mydomain.com/de/ (german site) http://www.mydomain.com/ads/cars/36/ http://www.mydomain.com/nl/ads/cars/36/ http://www.mydomain.com/de/ads/cars/37/ Basically we are planning to set up the English site under the main domain and language sites under a directory structure like the above, so the following would be valid: http://www.mydomain.com/ads/cars/36/ {shows content in English and uses a certain controller and view to do this} http://www.mydomain.com/sg/ads/cars/36/ (must use the same controller and view, but the site id will be different (stored in a session) and therefore display everything in the other language/country My question - how can I do this in ZF? In the IndexController, I know I can define functions for the above like this: public function adsAction() { } But then how do I make sure the same function is called if I go to a URL like this: http://www.mydomain.com/sg/ads/cars/36/ public function sgAction() { //set session site id as "sg" //redirect to adsAction() if /ads/ is the next item in the URL, or redirect to productsAction if the next item in the URL is "products", or redirect to indexAction if there is no "next" item in the URL } Can someone please let me know how to code this? I'm still a newbie... the complication comes in because the redirect depends on the URL. You may also have a URL like this: http://www.mydomain.com/?myparameter=1 http://www.mydomain.com/nl/?myparameter=1 Basically in both cases, I would want the indexAction to be called with the appropriate session siteid set, and the parameter would also need to be passed without change. Any advice on the best way to do this? Many thanks!