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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

Controller Routing


Go to End


3 Posts   1733 Views

Avatar
ColdBlooded

Community Member, 4 Posts

10 June 2013 at 4:22pm

Very confusing issue. Spent hours on digging but no joy. Allow me to explain:

I've followed the documentation on http://doc.silverstripe.org/framework/en/topics/controller but doesn't work.
Bumps me to this page (screenshot):

I have put this in _config.php:

Director::addRules(50, array(
'everything/$Action/$ID'=>'EverythingController'
));

No Joy.

I followed documentation at (http://doc.silverstripe.org/framework/en/topics/controller) - no joy. Same issue (See screenshot above).

How do I unable controller?

Source code for EverythingController.php:

<?php


class EverythingController extends Controller {
    
    function bio(){
        
        $id = $this->urlParams['ID'];
        $bio = DataObject::get_by_id("Bio",$id);
        return $this->renderWith("RoleSelect",array("Bio"=>$bio));
        
    }
}

?>

Everything I have done should work when I url to: link.com/everything/bio/2 - BUT IT DOESN'T

It always worked before. I think the issue came up when I started using the framework from the git repo at https://github.com/silverstripe/silverstripe-framework

Anyone with same issue?
Any solution / pointers / any guesses of what could be wrong?

Thank you.

Avatar
Willr

Forum Moderator, 5523 Posts

15 June 2013 at 8:36pm

Note that in 3.0 you should use the new config system for that - http://doc.silverstripe.org/framework/en/reference/director#routing

After you make any changes to the config system make sure you do a ?flush=1

Avatar
ColdBlooded

Community Member, 4 Posts

18 June 2013 at 8:42am

Hi Willr,

Thank you for your reply.

The solution was simply to have //$Action instead of /$Action in the _config.php file.