Membuat Recent Comments Portlet

Pada bagian ini, kita membuat portlet terakhir yang menampilkan daftar comment yang dipublikasi baru-baru ini.

Membuat Class RecentComment

Kita membuat class RecentComments di dalam file /wwwroot/blog/protected/components/RecentComments.php. File ini memiliki isi:



Di atas, kita memanggil method findRecentComments yang mendefinisikan class Comment sebagai berikut,



Membuat View recentComments

View recentComments disimpan di dalam file /wwwroot/blog/protected/components/views/recentComments.php. File view ini hanya menampilkan setiap comment yang dihasilkan oleh method RecentComments::getRecentComments().

Menggunakan Portlet RecentComments

Kita memodifikasi file layout /wwwroot/blog/protected/views/layouts/column2.php untuk menempelkan portlet terakhir ini.



$Id: portlet.comments.txt 1773 2010-02-01 18:39:49Z qiang.xue $