<?php defined('MW_PATH') || exit('No direct script access allowed');

/**
 * ArticleCategoriesWidget
 * 
 * @package MailWizz EMA
 * @author Serban George Cristian <cristian.serban@mailwizz.com> 
 * @link http://www.mailwizz.com/
 * @copyright 2013-2014 MailWizz EMA (http://www.mailwizz.com)
 * @license http://www.mailwizz.com/license/
 * @since 1.0
 */
 
class RecentPostWidget extends CWidget
{
     
    
    public function run()
    {
	 
			$articleCategoryFromSlug = ArticleCategory::model()->findByAttributes(array('slug'=>'blog'));
			$criteria=new CDbCriteria;
			$criteria->with = array('categories') ;
			$criteria->condition = 't.status=:pub and  categories.parent_id=:parent';
		 
			$criteria->params[':pub']   = 'published'  ;
			$criteria->params[':parent']   = $articleCategoryFromSlug->category_id  ;
			$criteria->together =true;
			$criteria->limit = 8;
			$model=Article::model()->findAll($criteria);
			$this->render('menu',compact('model'));
    }
}
