Set default presenter but not as homepage
- silviustan
- Member | 22
Hello,
First of all, please excuse me if I ask a stupid thing, but, I want to start with Nette but I have some troubles…
Is there any way to set a router with optional presenter (for example
“pages”) to obtain a link like this?
http://example.com/…cle-url.html → this means for me
presenter = pages, action(as default) = view, and article-url = param ?
I hope I described my problem well…
I hate urls like: http://example.com/…cle-url.html or http://example.com/…tegory-name/
In my opinion, “page” or “category” are unuseful because I can decide by param “article-url” or “my-category-name” is the entity is an article or a category. Related with these, another question comes: can I ask in a method of pages presenter to load other presenter/action without a redirect?
- Oli
- Member | 1215
It's about router. If you will use just 1 presenter you can have in RouterFactory something like
$router[] = new Route('<action=default>', array('presenter' => 'Homepage'));
and you can take some data from database and some slug from title use in url like
$router[] = new Route('<slug>', array(
'presenter' => 'pages',
'action' => 'default'
));
- silviustan
- Member | 22
Oli wrote:
It's about router. If you will use just 1 presenter you can have in RouterFactory something like
$router[] = new Route('<action=default>', array('presenter' => 'Homepage'));
and you can take some data from database and some slug from title use in url like
$router[] = new Route('<slug>', array( 'presenter' => 'pages', 'action' => 'default' ));
Thanks Oli! It looks like I didn't read very carefully documentation.
- honos
- Member | 109
Easily:
$router[] = new Route('<title>', array(
'presenter'=>'Homepage',
'action'=>'default',
'title'=>NULL));
If title is NULL show homepage. If title isnt NULL find in the articles and showes it and try find category this same name and show link references to it. if isnt articles found, find category … or something similar.
Sorry for my bad english, but Im from Russia and i dont speak english. Just try :o)
Last edited by honos (2014-01-23 07:31)