A
A
Arthur2015-10-05 23:55:27
Yii
Arthur, 2015-10-05 23:55:27

Yii2. How to connect shared and separate resources for specific controllers/modules?

We have an AppAsset that connects resources (shared) throughout the application. How to create for example PostAsset, which will connect only to the PostController controller.
Exactly the same question about modules. Created a Post module. How to connect resources for this module?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Александр, 2015-10-06
@r3st1k25

1. Создайте свой набор ресурсов PostAsset, аналогично AppAsset.
2. Подключайте его в нужном представлении контроллера или модуля:

use app\assets\PostAsset;
PostAsset::register($this);  // $this - представляет собой объект представления

PS. Для модуля это может быть app\modules\Post\assets\PostAsset.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question