mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Improved Link() docs
This commit is contained in:
parent
318073b05d
commit
53e790ff98
@ -54,17 +54,25 @@ making any code changes to your controller.
|
|||||||
so a `MyController` class is accessible through `http://localhost/MyController`.
|
so a `MyController` class is accessible through `http://localhost/MyController`.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Link
|
## Linking to a controller
|
||||||
|
|
||||||
Return the link for this Controller. Should return a value that makes sense with your custom route.
|
Each controller has a built-in `Link()` method,
|
||||||
|
which can be used to avoid hardcoding your routing in views etc.
|
||||||
|
The method should return a value that makes sense with your custom route (see above):
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
|
<?php
|
||||||
class FastFood_Controller extends Controller {
|
class FastFood_Controller extends Controller {
|
||||||
public function Link() {
|
public function Link($action = null) {
|
||||||
return 'fastfood';
|
return Controller::join_links('fastfood', $action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
The [api:Controller::join_links()] invocation is optional, but makes `Link()` more flexible
|
||||||
|
by allowing an `$action` argument, and concatenates the path segments with slashes.
|
||||||
|
The action should map to a method on your controller. `join_links()` also supports
|
||||||
|
|
||||||
|
|
||||||
## Access Control
|
## Access Control
|
||||||
|
|
||||||
### Through $allowed_actions
|
### Through $allowed_actions
|
||||||
|
Loading…
Reference in New Issue
Block a user