M
M
Messi2016-09-09 08:54:45
Yii
Messi, 2016-09-09 08:54:45

How to generate links?

I'm training with Yii2 advanced , making a blog. I have an admin panel and a website.
In the admin panel, I made CRUD blog post management, articles are created and displayed on the main page. But I need to make categories of news and each news also have hotel links.
Can you please tell me how to organize it? I read the Yii2
documentation on URL generation , but I didn’t understand the essence of the process, as I see it: 1. I create a table Categories(id, title) in the database , there will be lists of categories that I will create. 2. In the News table , make fields (id, title, category_id) 3. Now in CRUD


when creating a news, I will choose the category to which this news belongs and its title will be the final link (like mysite.com/category1/news1 ).
But how to do it on the site, because each page needs its own controller and its own views.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-09-09
@slo_nik

Good morning.
Why a separate controller and view?
Maybe this article will help you? Of course, if I understand you correctly.

B
Boris Yakushev, 2016-09-09
@za4me

According to the blog manuals.
Why such a conclusion?
Have you worked with MVC before?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question