문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top