Hi all,

Thanks to Syzmone and the rest of the group for helping me get started on 
creating a multiple language website using ZF. However I have a couple of 
problems making this 'efficient' and making my code less redundant.

Here is the kind of thing I want my site to do:

>> www.mydomain.com/products/boots/

>> www.mydomain.com/products/boots/paola/40/

>> www.mydomain.com/products/boots/paola/40/A/
>> www.mydomain.com/products/boots/paola/40/A/black/

>> www.mydomain.com/nl/products/boots/
>> www.mydomain.com/nl/products/boots/paola/40/
>> www.mydomain.com/nl/products/boots/paola/40/A/
>> www.mydomain.com/nl/products/boots/paola/40/black/

- The above says that an international site code may be passed, or may not. If 
not, the site will load in English. If "nl" is passed, it will load in Dutch.

- Also the above should call the "products" action in my index controller in 
all cases. If the product type is "boots" ,  a boots list page is displayed. If 
the style name (e.g. "Paola") is passed, then the detail page for paola is 
passed. Other parameters like shoe size (e.g. 40) width (e.g. "A") and colour 
(e.g. black) may also be passed.

Here is my bootstrap file, which sets up the routes:

/* default route */
    $route = new Zend_Controller_Router_Route(
        ':publicsitecode/:action/*',
        array(
            'publicsitecode' => 'uk',
            'controller' => 'index',
            'action'     => 'index'
        )
    );
    $router->addRoute('default', $route);

/* Routes to the products action*/
    $route = new Zend_Controller_Router_Route(
        ':publicsitecode/products/:producttype/:style/:size/:width/:colour/*',
        array(
            'controller' => 'index',
            'action'     => 'products',
            'publicsitecode' => 'uk',
            'producttype' => 'boots',
            'style'        => '',
            'size'        => 40,
            'width'        => '%',
            'color'        => '%'
        )
    );
    $router->addRoute('products', $route);
    


OK - so what the above should do is match the above URLs, but it doesn't  - 
which means I've misunderstood how this works a bit ;) I think the only way the 
above route will be matched is if I pass a URL like this:

http://www.duo-footwear.com/nl/products/boots/paola/35/A/black/

Now, even if I remove "nl" from the above, the route does not match, e.g.
http://www.duo-footwear.com/products/boots/paola/35/A/black/
- this goes to the default route and not the products route.

Even if I remove "black" (the colour) , the route is still not matched.

Therefore, if I understand correctly, I will need to create a new route for 
every possible combination of URL, meaning, for the above 8 URLs, I need to 
create 8 separate routers.

I am fine with this - but if I have missed something and there is indeed a way 
to say "this parameter is optional" in a route, but the route will still be 
matched if the parameter is missing" - then please do reply :)

Many thanks,
Rishi






      

Reply via email to