As usual, you can download it from the google code repositry and can try the demo out. Have fun
protected/components/MonthlyArchives.php:
<?php
class MonthlyArchives extends Portlet
{
public $title='Monthly Archives';
public function findAllPostDate()
{
$yearmonth = array();
$posts = Post::model()->findRecentPosts(PHP_INT_MAX);
foreach ($posts as $post) {
$ym = date('M, Y', $post->createTime);
if (!isset($yearmonth[$ym])) {
$yearmonth[$ym] = 1;
} else {
$yearmonth[$ym]++;
}
}
return $yearmonth;
}
protected function renderContent()
{
$this->render('monthlyArchives');
}
}
protected/components/views/monthlyArchives.php:
<ul>
<?php foreach ($this->findAllPostDate() as $month=>$val): ?>
<li>
<?php echo CHtml::link("$month ($val)", CHtml::normalizeUrl(array('post/PostedInMonth',
'time'=>strtotime($month),
'pnc'=>'c'))); ?>
</li>
<?php endforeach; ?>
</ul>

Help












