Post View Counter

Hello,

I search in yii portal, but i can’t find how to make a script to count view with MySql every time to view post add +1 to views and then reach count etc. 41.82 it should to be display 41.82K for shorter number :)

Sorry but im new in in yii and i try to learn about this :)

So if any can help, wrote here ;)

[color="#006400"]/* moved from Tips, Snippets and Tutorials */[/color]

Dear FRIEND

In Controller something like this.




public function actionView($id)

{

        $model=$this->loadModel($id);

        if (($count=Yii::app()->getGlobalState($model->title))==null)

		   Yii::app()->setGlobalState($model->title,1);

        else Yii::app()->setGlobalState($model->title,++$count);


	$this->render('view',array('model'=>$model));

}



In view something like this.




div style="float:right;color:green;">

<?php echo Yii::app()->getGlobalState($model->title).' view(s)';?>

</div>



I hope I helped a bit.

If I understood you correctly than you can check out this extension.