M
M
Messi2017-06-01 08:44:27
Yii
Messi, 2017-06-01 08:44:27

Block on all pages of the site?

There is a site on Yii2-basic, you need to get data from the database and display this data on all pages of the site (Block with a table).
What is the correct way to solve this problem using Yii2?
Would it be correct to add this block to views/layouts/main.php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-06-01
@FitTech

Receiving data from the database at the View level is not a good practice... Better implement a widget that will receive this data from the model and render the corresponding block (passing data into it). And display the widget itself in views/layouts/main.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question