pri vytvareni url pomoci n:href se mi tam tlaci /default/
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- vosy
- Člen | 532
chtel bych dosahnout teto url
http://www.ir.loc/novinka/9-mlady-ridic-dostal-v-centru-prahy-smyk-a-na-chodniku-smetl-tri-zeny
v routeru mam
$frontNovinkaRouter[] = new Route('novinka/[<id [0-9]+?><os \-.*>]','Novinka:default');
v latte
{var $nazev = $novinka->nadpis|replaceRE:'~<br>|\ ~':' '|striptags}
{var $url = $novinka->id.'-'.Nette\Utils\Strings::webalize($nazev)|truncate:50}
<a n:href="Novinka: $url" title="{$novinka->nadpis|truncate:50}" class="vice">více...</a>
a vysledna url je
http://www.ir.loc/novinka/default/9-mlady-ridic-dostal-v-centru-prahy-smyk-a-na-chodniku-smetl-tri-zeny
potreboval bych to bez toho /default/ :(
- vosy
- Člen | 532
<?php
use Nette\Application\Routers\RouteList,
Nette\Application\Routers\Route,
Nette\Application\Routers\SimpleRouter;
/**
* Router factory.
*/
class RouterFactory
{
/**
* @return Nette\Application\IRouter
*/
public function createRouter()
{
// if (isset($_SERVER['NETTE_HTACCESS'])) { // FastCGI
// $router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY);
// $router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
// } else {
// $router[] = new SimpleRouter('Homepage:default');
// }
$router = new RouteList();
//ADMIN
$router[] = $adminMenu2Router = new RouteList('Admin:Soutez');
$adminMenu2Router[] = new Route('admin/soutez/<presenter>/<action>/<id>',
array(
'action'=>'default',
'id'=>NULL
));
$router[] = $adminMenu2Router = new RouteList('Admin:ZakladniNastaveni');
$adminMenu2Router[] = new Route('admin/zakladni-nastaveni/<presenter>/<action>/<id>',
array(
'action'=>'default',
'id'=>NULL
));
$router[] = $adminRouter = new RouteList('Admin');
$adminRouter[] = new Route('admin/<presenter>/<action>/<id>',
array(
'presenter'=>'LoginBoard',
'action'=>'default',
'id'=>NULL
));
// FRONT
// $router[] = $frontRouter = new RouteList('Front:JakNaTo');
// $frontRouter[] = new Route('jak-na-to/<presenter>/<typ>',
// array(
// 'presenter'=>'JakObjednat',
// 'action'=>'default',
// 'typ'=>NULL
// ));
//
$router[] = $XRouter = new RouteList('Front');
$XRouter[] = new Route('sitemap.xml', 'Sitemap:');
$router[] = $frontKontaktRouter = new RouteList('Front');
$frontKontaktRouter[] = new Route('kontakty/<jmeno>/<id>',
array(
'presenter'=>'Kontakty',
'action'=>'kontakt',
'id'=>NULL
));
$router[] = $frontKontaktRouter = new RouteList('Front');
$frontKontaktRouter[] = new Route('soutez/<step>',
array(
'presenter'=>'Homepage',
'action'=>'soutez',
'id'=>NULL
));
$router[] = $frontInvesticeRouter = new RouteList('Front:Investice');
$frontInvesticeRouter[] = new Route('investice/<presenter>/<action>/<id>',
array(
'presenter'=>'Investice',
'action'=>'default',
'id'=>NULL
));
$router[] = $frontNovinkyRouter = new RouteList('Front');
$frontNovinkyRouter[] = new Route('novinky[/<vp-page [0-9]+>]',
array(
'presenter'=>'Novinky',
'action'=>'default',
'vp-page'=>1
));
$router[] = $frontNovinkaRouter = new RouteList('Front');
$frontNovinkaRouter[] = new Route('novinka/[<id [0-9]+?><os \-.*>]','Novinka:default');
$router[] = $frontRouter = new RouteList('Front');
$frontRouter[] = new Route('<presenter>/<action>/<id>',
array(
'presenter'=>'Homepage',
'action'=>'default',
'id'=>NULL
));
return $router;
}
}
Editoval vosy (29. 1. 2014 16:38)
- David Matějka
- Moderator | 6445
az ted jsem se kouknul, jak ten odkaz vytvaris.. to nemuze samozrejme fungovat, jelikoz tam mas jen jeden parametr (to $url) a v route vyzadujes „id“ a „os“, takze
{var $nazev = $novinka->nadpis|replaceRE:'~<br>|\ ~':' '|striptags}
{var $url = $nazev|webalize|truncate:50}
<a n:href="Novinka: id=>$novinka->id, os=>$url" title="{$novinka->nadpis|truncate:50}" class="vice">více...</a>
(ale predelej, abystu url newebalizoval a netruncatoval v salone, ale pomoci filtru na route)