...
Code Block | ||||
---|---|---|---|---|
| ||||
<?php namespace Apps\TodoList\Controller; class ViewController extends \Phpfox_Component { public function process(){ $template = $this->template(); // add your section menus $template->buildSectionMenu('to-do-list', [ 'Browse' => $this->url()->makeUrl('/to-do-list'), 'Create' => $this->url()->makeUrl('/to-do-list/add'), ]); $template->menu('Add To Do', $this->url()->makeUrl('/to-do-list/add')); $id = $this->request()->get('req3'); $browseService = \Phpfox::getService('todo'); $aItem = $browseService->getForBrowse($id); $url = $this->url()->permalink('to-do-list.view', $aItem['task_id'], $aItem['name']); $template ->setTitle($aItem['name']) ->setBreadCrumb($aItem['name'], $url); $template->assign([ 'aItem'=>$aItem, ]); } } |
{{ Wiki Markup $this-
>request>request()-
>get('req3')}} is used to get the third value in the url. For example:>get('req3') is used to get the third value in the url. For example: [http://
{}/index.php/
{}/
{}/
{}/]...
In
this
case,
current
url
is:
[http://
{}/index.php/to-do-list/view/
{}/
{}],
so
{{>get('req3')}} will return the id of the Todo List
request()-
>get('req3')
will return the id of the Todo List
...
Code Block | ||||
---|---|---|---|---|
| ||||
$module->addComponentNames('controller', [ 'toto.view' => Controller\ViewController::class, ]) |
Code Block | ||||
---|---|---|---|---|
| ||||
route('to-do-list/view/:id/:name', function () { \Phpfox_Module::instance()->dispatch('todo.view'); return 'controller'; }); |
Let's review the previous chapter a little bit, after clicking the link {code:actionscript3} Wiki Markup Let's review the previous chapter a little bit, after clicking the link
Code Block | ||||
---|---|---|---|---|
| ||||
<a href="{ permalink module='todo.view' id=$aItem.task_id title=$aItem.name }">
|
...
it
...
will
...
redirect
...
you
...
to
...
the
...
controller
...
todo.view
...
that
...
you
...
had
...
registered
...
in
...
start.php
...
,
...
that
...
means
...
you
...
will
...
be
...
redirected
...
to
...
the
...
url:
...
[http://
...
...
/index.php/to-do-list/view/
...
...
/
...
...
],
...
thus,
...
the
...
route
...
for
...
todo.view
...
controller
...
has
...
to
...
be
...
'to-do-list/view/:id/:name
...
' in
...
order
...
to
...
redirect
...
and
...
pass
...
request
...
parameters
...
correctly.
...
Tip
*:
You
can
also
simply
register
route
as:
to-do-list/view/_
-
"_" means you can put as many requests as you want."_" means you can put as many requests as you want.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<h4>Name</h4> <p>{$aItem.name}</p> <h4>Description</h4> <p>{$aItem.description}</p> <h4>Status</h4> <p>{ if $aItem.task_status >0 }complete{else}in-complete{/if}</p> <h4>Created</h4> <p>{$aItem.time_stamp|convert_time}</p> |
...