1

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?

tereško
  • 58,060
  • 25
  • 98
  • 150
Arek S
  • 4,239
  • 4
  • 24
  • 33

1 Answers1

1

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.

Bogdan Burym
  • 5,482
  • 2
  • 27
  • 46