Also available in these languages:
English日本語polskiРусский简体中文

Future Enhancements

Using a Theme

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:

return array(
    ......
    'theme'=>'classic',
    ......
);

Internationalization

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 index page of PostController, we can create a view file /wwwroot/blog/protected/views/post/zh_cn/index.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.

Improving Performance with Cache

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/column2.php, we can enclose the tag cloud portlet with COutputCache:

<?php if($this->beginCache('tagCloud', array('duration'=>3600))) { ?>
 
    <?php $this->widget('TagCloud', array(
        'maxTags'=>Yii::app()->params['tagCloudCount'],
    )); ?>
 
<?php $this->endCache(); } ?>

With the above code, the tag cloud display will be served from cache instead of being generated on-the-fly for every request. The cached content will remain valid in cache for 3600 seconds.

Adding New Features

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.

$Id: final.future.txt 2017 2010-04-05 17:12:13Z alexander.makarow $
If you find any typos or errors in the tutorial, please create a Yii ticket to report it. If it is a translation error, please create a Yiidoc ticket, instead. Thank you.

Total 1 comment:

#523
another important and nice enchament
by callmeblessed at 7:30pm on July 31, 2009.

please make a yii console to wrap all files that need to be uploaded (including the framework itself)

like "yii make" and it will produce zip file with php installer (eg: installer.php and web-app-name.tar.gz)

Your Comment:

You may enter comment using Markdown syntax.

Please login with your forum account.
Note: you must have at least ONE forum post with your account.