I have quite a trivial (I think the question). I recently started to learn Yii and I can’t figure it out yet. The point is this: We are developing a site with 2 types of pages:
- “Static”, whose call is specified by actionMethod () methods in the corresponding controller. For them, there are views, and they reflect the basic structure of the site (in the main menu). URL: mysite.ru/product/
- Added by admin through backend-interface. They are subsections of the main sections and may be present in the submenu of the main menu. URL: mysite.ru/product/osago
... where osago is the alias of the type of product in the database. In fact, neither the osago page nor the folder exists. After extracting data from the database, they should be placed in a template. The challenge is that when calling the productController controller, it does not send us on page 404. We cannot have an actionMethod for each type of product, since they can be added at any time. Accordingly, it should:
Check for actionMethod () in the controller. If found, acts in the usual manner, i.e., calls this method.
If not found, search for alias extracted from the URL in the database. If found, then get the data and place in the template for the product.
If not found, send on p. 404.
Actually, it is not quite clear how to fulfill condition 2. Surely, the task is standard for those who are well acquainted with Yii. I would be very grateful to my dear colleagues for the answers on the merits. Thank!