Jump to:

23360 Posts in 18124 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Director::addRules() mystery

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

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

Page: 1
Go to End
Author Topic: 2019 Views
  • aragonne
    Avatar
    Community Member
    26 Posts

    Director::addRules() mystery Link to this post

    Hi, I'm trying to define a custom rewrite rule in my _config.php:

    Director::addRules(50, array(
    'Feed//$Action/$LoginName/$Password/$LastModDate/$DeleteMode' => 'FeedEngine',
    ));

    However, when I try to access the url:

    http://mysite.com/Feed/Go/labcorp/abc123/1234/0

    I get a "I can't handle sub-URLs of a FeedEngine object" message.

    Any idea why this is happening? The Go() method does exist in the FeddEngine class (which is a subclass of Controller).

    thanks,
    Steve

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Director::addRules() mystery Link to this post

    you have...

    SiteTree::enable_nested_urls();

    ... in your _config.php?

  • aragonne
    Avatar
    Community Member
    26 Posts

    Re: Director::addRules() mystery Link to this post

    Hi Swaiba,

    Yes, I do have nested urls enabled.

    I updated the setting above by removing the double slash after 'Feed' and the error message disappeared. I tried to find out what the double slashes mean, but I couldn't find anything in the SS docs or forum. I saw it being used in the sapphire/_config.php file and it looks like a delimiter between the url segment and the params so I copied the format.

    Anybody have explanation as to what the double slashes mean?

    thanks again,
    Steve

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Director::addRules() mystery Link to this post

    The double slashes define a shift point in the URL - basically everything before the slashes is shifted off, and the stuff after it is passed to the actual controller to handle as it sees fit. This would have meant that your controller was passed everything after "Feed" to handle. Since it then didn't have a matching rule defined in $url_handlers, it errored out.

    2019 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.