The layout file of Yii2 can generally satisfy the loading of most public files, but there are still some situations where it cannot be satisfied, such as a common part in some pages. The situation is more difficult to handle. Of course, you can write it once on every page, Ctrl C, Ctrl V, it won't waste much time.
But when this public part needs to be modified, it becomes more troublesome. The following is the solution for loading public files:
1. Use JS to define public methods and do it on the page that needs to be loaded. Loading
2. Use widgets (Widgets) and define widgets to perform loading
3. Use beginContent to load files directly
PHP Chinese website, there are a lot of freeYii Getting Started Tutorial, everyone is welcome to learn!
The above is the detailed content of How to import public files into Yii. For more information, please follow other related articles on the PHP Chinese website!