Creating Recent Comments Portlet

In this section, we create the last portlet that displays a list of comments recently published.

Creating RecentComments Class

We create the RecentComments class in the file /wwwroot/blog/protected/components/RecentComments.php. The file has the following content:



In the above we invoke the findRecentComments method which is defined in the Comment class as follows,



Creating recentComments View

The recentComments view is saved in the file /wwwroot/blog/protected/components/views/recentComments.php. It simply displays every comment returned by the RecentComments::getRecentComments() method.

Using RecentComments Portlet

We modify the layout file /wwwroot/blog/protected/views/layouts/column2.php to embed this last portlet,



$Id$