Sunday, 15 August 2010

php - How to access a variable from the model in view (Yii framework)? -



php - How to access a variable from the model in view (Yii framework)? -

have model:

public static function newmessagescount() { $count = 0; $currentuser = yii::app()->user->id; // build criteria user have new messages $criteria = new cdbcriteria(); $criteria->condition = 'to_id = :to_id , is_read = :is_read'; $criteria->params = array(':to_id' => $currentuser, ':is_read' => 0); //count items if (message::model()->exists($criteria)) { $count = message::model()->count($criteria); } homecoming $count; }

i need access in form of $count. illustration this:

<li class="btn btn-primary white"><i class="icon-download"></i><?php echo chtml::link('inbox', array('message/inbox')); ?></li><?message::newmessagescount()?>

you not outputting function result. utilize echo message::newmessagescount() in view.

php yii

No comments:

Post a Comment