Tuesday, December 17, 2013

yii php develop log – bootstrap TbThumbnails widget

1.screenshots:

url:http://localhost/mw2/exam/exam/locale

image

2.code

mw2\protected\modules\exam\views\exam\locale.php:

<?php 
$this->widget('bootstrap.widgets.TbThumbnails', array(
'dataProvider'=>new CArrayDataProvider(Yii::app()->getModule('rss')->getLocaleList()),
'template'=>"{items}\n{pager}",
'itemView'=>'_localethumb',
));

?>



mw2\protected\modules\exam\views\exam\_localethumb.php:

<li class="span3">
<a href="#" class="thumbnail" rel="<?php echo $data['country'] ?>" data-title="<?php echo $data['country'] ?>">
<img src="/s/images/flags/<?php echo $data['locale'] ?>.png" alt="<?php echo $data['country'] ?>">
</a>
</li>




mw2\protected\modules\rss\RssModule.php:

<?php

class RssModule extends CWebModule
{
//... other code

public function getLocaleList($all = false){
$rows = RssLocaleModel::model()->findAll($all ? null : 'rssstatus=1');
$ret = array();
foreach($rows as $row)
$ret []= $row->getAttributes();
return $ret;
}

}




data table pkrss_rsslocale:

CREATE TABLE `pkrss_rsslocale` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`locale` varchar(32) NOT NULL,
`country` varchar(64) DEFAULT NULL,
`encoding` varchar(32) DEFAULT 'utf-8',
`defaultcatalogid` int(11) NOT NULL,
`ucatid` int(11) NOT NULL,
`rssstatus` int(11) NOT NULL DEFAULT '0',
`timezone` varchar(64) DEFAULT NULL,
`pid` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `locale` (`locale`),
KEY `defaultcatalogid` (`defaultcatalogid`)
)



3.end


thanks!

No comments: