stare adresy na nove s filtrem s databazi
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- bauer01
- Člen | 30
Ahoj,
stary web nebezel v nette a mel tento typ adres:
domena.cz/skript.php?type=clanek&id=236
novemu webu odpovida tato adresa:
domena.cz/clanky/titulek-patricnemu-clanku
Potrebuji vsak zachovat funkcnost starych linku, dalo by se to udelat routou s flagem Route::ONE_WAY?
muj bootstrap.php
$container->router[] = new Route("index.php", "Front:Homepage:default", Route::ONE_WAY);
// Admin module
$container->router[] = $admin = new RouteList("Admin");
$admin[] = new Route("admin/<presenter>/<action>", "Homepage:default");
// Front module
$container->router[] = $front = new RouteList("Front");
$front[] = new Route("clanek/<id>", array(
"presenter" => "Homepage",
"action" => "article",
"id" => array(
Route::VALUE => NULL,
Route::FILTER_IN => function($title) use ($tools) {
return $tools->getIdByTitle($title);
},
Route::FILTER_OUT => function($id) use ($tools) {
return $tools->getTitleById($id);
},
),
));
$front[] = new Route("<presenter>/<action>[/<id>] ? strana=<paginator-page>", "Homepage:default");
Zkusil jsem nasledujici, ale vyskoci na me „Invalid value for parameter ‚id‘, expected integer.“:
$front[] = new Route("skript.php ? id=<id>", array(
"presenter" => "Homepage",
"action" => "article",
"id" => array(
Route::VALUE => NULL,
Route::FILTER_IN => function($title) use ($tools) {
return $tools->getIdByTitle($title);
},
Route::FILTER_OUT => function($id) use ($tools) {
return $tools->getTitleById($id);
},
),
), Route::ONE_WAY);
v presenteru mam:
namespace FrontModule;
class HomepagePresenter extends BasePresenter
{
public function renderArticle($id = 0)
{
$id = (int) $id;
...
}
}
Dik za pripadne rady