Hi,
I have a question on Zend_Controller_Router_Route. We need our site "help"
section to be accessible like this:
www.mysite.com/de/helpde/ ---> Goes to the German page "help" section (I've
just
named it "helpde" but need to get the transalation)
www.mysite.com/nl/hilfe/ ----> Goes to the Dutch site "help" section
www.mysite.com/help/ ----> Goes to the UK site "help" section
There will also be sub sections for the help section, such as
www.mysite.com/de/helpde/subcat1/ ---> German subcategory
www.mysite.com/nl/hilfe/subcat2/ ----> Dutch subcategory
www.mysite.com/help/orders/ ----> UK subcategory for "orders" help
My questions:
1) Firstly I never knew how to set up one route for the UK and Euro sites
combined, so I always set up a UK route separately (since the UK site above
does
not have a site code "uk" for example, it just is accessed from the main domain
www.mysite.com . So I actually add two separate routes, one for UK and one for
all other Euro sites (Dutch and German). If there is a simple way to tell
Zend_Controller_Router_Route that "nl" and "de" are optional, and if not
passed,
then assume "uk" is the sitecode, could someone tell me what code to use here?
2)
a) My more pressing question is - how to set up the above help route. I tried
the following for Euro sites (I can repeat another route for the UK site as
explained in point 1). This is in bootstrap.php -
$route = new
Zend_Controller_Router_Route(':publicsitecode/:help_sef_url/:sef_url/*',
array(
'controller' => 'index',
'action' => 'help',
'sef_url' => '',
'help_sef_url' => 'help'
),
array(
'help_sef_url' => 'help|hilfe|helpde'
)
); /* The above says that the Euro sites should call the helpAction if the
URL has help, hilfe, or helpde as the second argument. */
$router->addRoute('helppage_intl', $route);
The above works great, except, the website home page www.mysite.com/nl/ for
example also goes to this route and tries to load the helpAction. The reason is
because, the first, second and third arguments are all treated as OPTIONAL.
What
I'd like to do is tell the route that "help_sef_url" (and publicsitecode) are
MANDATORY fields for this route - so do not load the helpAction unless the URL
contains
www.mysite.com/nl/help/
www.mysite.com/nl/helpde/
www.mysite.com/nl/hilfe/
etc.
I'm just experimenting by trying different URLs and the above does work except
for the home page incorrectly loading the helpAction. Is there a way I could
fix
this?
b) I tried using the Regex route but I've had some trouble understanding
regular
expressions, I believe the below is correct but it doesn't work completely, I
can check into this more only if Zend_Controller_Router_Route above cannot
solve
my issue.
$route = new
Zend_Controller_Router_Route_Regex('(de|fr|nl)/(help|hilfe|helpde)(?:/(.+))',
array(
'controller' => 'index',
'action' => 'help'
),
array(
'1' => 'sitecode',
'2' => 'help_sef_url',
'3' => 'sef_url'
)
);
$router->addRoute('helppage_intl', $route);
c) Finally I can also simple set up different routes for the different sites -
that is simple and that is what I'm doing now until I understand how to fix the
issue above.
Would appreciate any help, many thanks in advance!
Rishi