php - CakePHP 4 sub view or sub action routing

In cakePHP 4

I have a controller and view.php connected with it. I can use a route like this: sitename.com/projects/45, where 45 - is sample project ID.

Using this url I can reach a page with the content of particular project. But If I want to construct something like a page of settings of this project, how I have to do it?

For example via url sitename.com/projects/45/settings

Help please

Answer

Solution:

It's simple:

// sitename.com/projects/45

// public function view($id) { ... }


// sitename.com/projects/45/settings

public function view($id, $passed = null) {
    if($passed == 'settings') {
       // do ...
    }
}

or

public function view($id) {
    $passed = $this->getRequest()->getParam('pass');
    if (in_array('settings', $passed)) {
      // do ...      
    }
}

Source