Future Enhancements in Blogging using YII Framework

Jul 21
08:34

2016

Aini clive

Aini clive

  • Share this article on Facebook
  • Share this article on Twitter
  • Share this article on Linkedin

As we all know that writing is one of the pillars of rich content. Now days it is less important than it was few years ago. Where is this heading? There are some trends which will have a huge impact in the future of blogging. These trends are applying pressure to your ability to succeed with long-form content on the web.

mediaimage
Internationalization

For the future enhancements using Yii you need to internationalize your blog application so that its pages can be viewed in different languages. There are two aspects of enhancement in blogging.

First,Future Enhancements in Blogging using YII Framework Articles we can create the view files in different languages. For example, for the index page of PostController, we can create a view file like /wwwroot/blog/protected/views/post/zh_cn/index.php. This application has been configured to use simplified Chinese (language code is zh_cn); using yii will automatically use this new view file instead of the original one.

Second, we need to create message translations for those messages generated by code. These message translations should be saved as file under the directory /wwwroot/blog/protected/messages. If we are using text strings then we need to modify the code by enclosing them in the method call yii::t ().

How to use a Theme

Our blog is already themeable by default, even if we don’t write any code. In order to use the theme we need to develop the theme by writing customized view files in the theme. For example, if we want to use a theme named classic that uses a different page layout, we need to create a layout view file./wwwroot/blog/themes/classics/views/layouts/main.php. We also may change the application configuration to indicate our choice of classic theme:

Return array (

…………….

`theme’=>’ classic’,

…………..

);

Improvement in caching feature

Though yii framework is very efficient but it is not necessarily true that any application which is written in Yii framework is efficient. There are several enhancement rooms in our blog application to improve the performance. For example, the tag cloud portlet could be one of the performance bottlenecks due to its complex database query and php logic.

We can improve performance by creating sophisticated caching feature by Yii framework. One of the very common and useful components in Yii is COutputCache, which caches the fragments of display so that the code behind the application 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:

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

This is the code which is used to create the display from cache instead of being generated on every request. The content in the cache will be valid for 3600 seconds.

Addition of New Features

Our blog is not that efficient that its applications are having very advance functionalities but it is sure that it has got the basic functionalities. There is a need of lot of effort to become a complete blog system. Still more features needed every time, for example, email notifications, post categorization, archived post portlet , calendar portlet, and so on. The final deployment and the tune-up of the framework come with the following enhancements. For example, changing Home Page, Enabling Schema Caching, Disabling Debugging Mode and Deploying the Application. Readers of this article are not required to have a prior knowledge about Yii but, basic knowledge of object oriented programming and database programming would help the readers to understand the article.