Future Enhancements

Without writing any code, our blog application is already themeable. To use a theme, we mainly need to develop the theme by writing customized view files in the theme. For example, to use a theme named classic that uses a different page layout, we would create a layout view file /wwwroot/blog/themes/classic/views/layouts/main.php. We also need to change the application configuration to indicate our choice of the classic theme:

We may also internationalize our blog application so that its pages can be displayed in different languages. This mainly involves efforts in two aspects.

First, we may create view files in different languages. For example, for the list page of PostController, we can create a view file /wwwroot/blog/protected/views/post/zh_cn/list.php. When the application is configured to use simplified Chinese (the language code is zh_cn), Yii will automatically use this new view file instead of the original one.

Second, we may create message translations for those messages generated by code. The message translations should be saved as files under the directory /wwwroot/blog/protected/messages. We also need to modify the code where we use text strings by enclosing them in the method call Yii::t().

For more details about internationalization, please refer to the Guide.

While the Yii framework itself is very efficient, it is not necessarily true that an application written in Yii efficient. There are several places in our blog application that we can improve the performance. For example, the tag clould portlet could be one of the performance bottlenecks because it involves complex database query and PHP logic.

We can make use of the sophisticated caching feature provided by Yii to improve the performance. One of the most useful components in Yii is COutputCache, which caches a fragment of page display so that the underlying code generating the fragment does not need to be executed for every request. For example, in the layout file /wwwroot/blog/protected/views/layouts/main.php, we can enclose the tag cloud portlet with COutputCache:

Our blog application only has very basic functionalities. To become a complete blog system, more features are needed, for example, calendar portlet, email notifications, post categorization, archived post portlet, and so on. We will leave the implementation of these features to interested readers.