diff options
author | Frédéric Guillot <fred@kanboard.net> | 2018-04-06 10:54:58 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2018-04-06 10:54:58 -0700 |
commit | 0b306fa60ad84ea077111e0ff7b59208ba7bc8a3 (patch) | |
tree | 5d8941b5950ede2db8ca3fba0213792db0f07a50 /doc/en_US/plugin-routes.markdown | |
parent | ac11220a1aa7ae30b8827d9bbf221888d3edd0a7 (diff) |
Move documentation to https://docs.kanboard.org/
Diffstat (limited to 'doc/en_US/plugin-routes.markdown')
-rw-r--r-- | doc/en_US/plugin-routes.markdown | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/doc/en_US/plugin-routes.markdown b/doc/en_US/plugin-routes.markdown deleted file mode 100644 index b943bb19..00000000 --- a/doc/en_US/plugin-routes.markdown +++ /dev/null @@ -1,85 +0,0 @@ -Custom Routes -============= - -When URL rewriting is enabled, you can define custom routes from your plugins. - -Define new routes ------------------ - -Routes are handled by the class `Kanboard\Core\Http\Route`. - -New routes can be added by using the method `addRoute($path, $controller, $action, $plugin)`, here an example: - -```php -$this->route->addRoute('/my/custom/route', 'myController', 'myAction', 'myplugin'); -``` - -When the end-user go to the URL `/my/custom/route`, the method `Kanboard\Plugin\Myplugin\Controller\MyController::myAction()` will be executed. - -The first character of the controller and the plugin name will converted in uppercase with the function `ucfirst()`. - -You can also define routes with variables: - -```php -$this->route->addRoute('/my/route/:my_variable', 'myController', 'myAction', 'myplugin'); -``` - -The colon prefix `:`, define a variable. -For example `:my_variable` declare a new variable named `my_variable`. - -To fetch the value of the variable you can use the method `getStringParam()` or `getIntegerParam()` from the class `Kanboard\Core\Http\Request`: - -If we have the URL `/my/route/foobar`, the value of `my_variable` is `foobar`: - -```php -$this->request->getStringParam('my_variable'); // Return foobar -``` - -Generate links based on the routing table ------------------------------------------ - -From templates, you have to use the helper `Kanboard\Helper\Url`. - -### Generate a HTML link - -```php -<?= $this->url->link('My link', 'mycontroller', 'myaction', array('plugin' => 'myplugin')) ?> -``` - -Will generate this HTML: - -```html -<a href="/my/custom/route">My link</a> -``` - -### Generate only the attribute `href`: - -```php -<?= $this->url->href('My link', 'mycontroller', 'myaction', array('plugin' => 'myplugin')) ?> -``` - -HTML output: - -```html -/my/custom/route -``` - -HTML output when URL rewriting is not enabled: - -```html -?controller=mycontroller&action=myaction&plugin=myplugin -``` - -### Generate redirect link: - -From a controller, if you need to perform a redirection: - -```php -$this->url->to('mycontroller', 'myaction', array('plugin' => 'myplugin')); -``` - -Generate: - -``` -?controller=mycontroller&action=myaction&plugin=myplugin -``` |