Jump to:

22977 Posts in 11758 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Controller gets a page-not-found

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: 1415 Views
  • eceers
    Avatar
    Community Member
    24 Posts

    Controller gets a page-not-found Link to this post

    Hi All,

    I have this Controller;

    class VideoDisplay_Controller extends Controller
       {
          static $allowed_actions = array(
             'action' => true
          );
          function action($arguments) {
             return 'Something';
          }
       }

    Which I'm setting up with;

    Director::addRules(20, array('video-display/$Action/$Type/$Id/' => 'VideoDisplay_Controller'));

    When I try accessing the controller through http://localhost/video-display/action I get a page-not-found.

    I'm using 2.4

    The only mention of this type of behaviour I found on this page http://www.balbus.tk/simulating-page-urls/ but he doesn't mention how to fix it.

    Any help would be greatly appreciated.

  • eceers
    Avatar
    Community Member
    24 Posts

    Re: Controller gets a page-not-found Link to this post

    Not sure if this is the problem or if there is another reason. It appears that Silverstripe is not seeing the Controller file at all. I have created an obvious parse error and it does not catch it on the server.

    I have delved into the documentation and everything I have found says that I'm doing the right thing but alas it no workie

    I really need some help with this if anyone can help please.

  • martimiz
    Avatar
    Forum Moderator
    1037 Posts

    Re: Controller gets a page-not-found Link to this post

    Just in case you're still looking for a solution: you did everything about right. It should work and it probably will once you remove the trailing slash after $Id from the Director rule like so:

    Director::addRules(20, array('video-display/$Action/$Type/$Id/' => 'VideoDisplay_Controller'));

    replace by

    Director::addRules(20, array('video-display/$Action/$Type/$Id' => 'VideoDisplay_Controller'));

    The problem: for some reason, if you add the trailing slash, SilverStripe will treat it as if another empty(!) parameter is added to the rule, and will try to match it (in HTTPRequest::match()), and fail. I don't know if this is 'by design', but if not, it would be nice to filter it out, since this is a typo easily made.

    Cheers, Martine

    1415 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.