Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Director::addRules [SOLVED]


Go to End


2 Posts   1472 Views

Avatar
Lukin

Community Member, 56 Posts

2 August 2012 at 11:49pm

Edited: 02/08/2012 11:51pm

HI
I need to simulate several urls.

Pages:
1. categories
a. subCategoryA
b. subCategoryB

2. products
a. productTypA
- product1
- product2
b. productTypB
- product 3

I try to simulate a url like this:
categories/subCategoryA/productTypB/product 3

I use this Director::Rule to handle my requests:

Director::addRules(100, array(
'categories//$subCategory!/$productTyp' => 'Hauptkategorie_Controller'
));

and this handler (read the comments):

public static $url_handlers = array(
'' => 'index',
//works ->URL:http://website.xx/categories

'$subCategory' => 'subCategory',
//works ->URL:http://website.xx/categories/subCategory

'$subCategory/$productTyp' => 'test'
// does not work. I'm getting a 404 ->URL:http://website.xx/categories/subCategory/productTyp
);

I think calling the url http://website.xx/categories/subCategory/productTyp does not match the rule, but I don't understand why.

Any help appreciated

Thanks in advance

Lukin

Avatar
Lukin

Community Member, 56 Posts

3 August 2012 at 7:08pm

Edited: 03/08/2012 7:12pm

This is working ....

Caution! Don't forget the '!'

in my _config
Director::addRules(100, array(
'cateories//$subcategories/$producttyp/$product' => 'Hauptkategorie_Controller'
));

in my handler:
public static $url_handlers = array(
'$subcategories/$producttyp/$product!' => 'test4',
'$subcategories/$producttyp!' => 'test3',
'$subcategories!' => 'test2',
'' => 'test1'
);

cheers ;)