Pergunta

In a layout I need to display number of notifications.

what is the right way of doing it? I'm thinking to create a widget for it but is accessing DB while rendering view correct?

Foi útil?

Solução

Yes, it is ok to create a widget for this needs.

After done, it is ok to call it from layout.

You can even use caching in order not to bother DB too often.

http://www.yiiframework.com/wiki/17/how-to-make-use-of-a-fragment-cache/

Finally: I would recommend writing widget and using it with fragmental caching.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top