Help with diverse routing

Notice: This thread is very old.
svanda777
Member | 14
+
0
-

Hello,
I am beginner at Nette and I need help with routing.

I need this:
/home PagePresenter:default (parameter home)
/home/upravit PagePresenter:edit (parameter home)
/function PagePresenter:default (parameter funkce)
/news PostPresenter:default (parameter novinky)
/news/add PostPresenter:add (parameter novinky)
/news/delete/1 PostPresenter:deleter (parameters novinky,1)
/homeworks PostPresenter:default (ukoly)
/login SignPresenter:default
/registration SignPresenter:register
/logout SignPresenter:logout

This was only a fraction of all possible URLs.

I have two ideas:

  1. Create a special event for every presenter except PagePresenter, which contains only text.

/news NewsPresenter
/homework HomeworkPresenter
/login LoginPresenter
/home PagePresenter
/function PagePresenter

  1. Save presenter and action into database.

It's not about the code, but rather would be interested in your opinion of the way to do it.

In the first option is, in my opinion, the problem that the project will include a lot of classes, which will be a lot of code repeated. But on the other hand, the project will probably be clearer (not need code to be divided into branches according to parameter).
In the second possibility I do not know how it should look about database scheme and programming route would be little more complicated.

Thank you.

amik
Member | 118
+
0
-

A bit late answer, but:

  • why (and what) do you want to save to database? Routes are usually written directly in your app's code, which is the correct solution in 99% cases.
  • what is exactly your problem? you don't know how to write routes properly? Why don't you use something like this: https://doc.nette.org/…tion/routing#… ?