D
D
dkrylov2017-04-18 12:20:23
MySQL
dkrylov, 2017-04-18 12:20:23

How to correctly implement static data output in yii2?

Hello ;)
While continuing to learn yii2, I came across such a problem.
In the simplest case: there is a "Contacts" page, it has a block with a feedback form (on the right), at the bottom there is a map, and to the left of the feedback form there is a block with text (phone number, email, etc.).
This text should be edited in the admin panel, respectively, it is necessary to make a `page` table (exaggerated):
id | page_content
And the question arises, how to display such data? Correctly I think - to make a widget for them, and in the place where the data should be displayed, initialize it? Because There are other pages, for example the main one.
And what to do if, for example, on the page of the same name there should be 2-3 blocks with such data?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-04-18
@dkrylov

Good afternoon.
You can write this data in the params.php file. Output like this: You can make a settings module. You can do as you say, the page table and display the information you need on the "contacts" page. There are many options.

M
Maxim Timofeev, 2017-04-18
@webinar

Here it is worth breaking the problem into several.
1. How to store - in the database
2. How to receive and edit - I would make a component for such things, conditionally "site settings", under it 1 or several pages, would receive data and cache for an indefinite period, would clear the cache when acting in CRUD in the admin. It is convenient to receive something like this:
3. How to display - here either your widget or block ( www.yiiframework.com/doc-2.0/yii-widgets-block.html ) or just a separate view.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question