#425 首页添加新闻的焦点轮播功能

This commit is contained in:
Li Jianxuan 2012-12-27 08:42:56 +00:00
parent 11dd20a220
commit c47de7ae12
6 changed files with 148 additions and 79 deletions

View File

@ -2,6 +2,13 @@
class IndexController extends Zend_Controller_Action class IndexController extends Zend_Controller_Action
{ {
function preDispatch()
{
$this->view->config = Zend_Registry::get('config');
$this->db=Zend_Registry::get('db');
$this->view->theme = new Theme();
}
function indexAction() function indexAction()
{ {
//数据通讯 //数据通讯
@ -46,11 +53,22 @@ class IndexController extends Zend_Controller_Action
$searchform=new SearchForm(); $searchform=new SearchForm();
//$searchform->removeElement('submit'); //$searchform->removeElement('submit');
$this->view->searchform=$searchform; $this->view->searchform=$searchform;
}
function preDispatch() $News = new Archive($this->db);
{
$this->view->config = Zend_Registry::get('config'); $time = date("Y-m-d H:i:s",time());
$this->db=Zend_Registry::get('db'); $sql = "SELECT * FROM archive WHERE is_pub=true AND ts_published<'$time' AND image!='' LIMIT 5";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH);
foreach($rows as $k=>$v)
{
$url = $News->getArchiveUrlByCid($v['id']);
$rows[$k]['url'] = $url['archive_url'];
}
$this->view->news = $rows;
} }
} }

View File

@ -3,6 +3,8 @@
$this->headTitle('首页'); $this->headTitle('首页');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/index.css'); $this->headLink()->appendStylesheet('/css/index.css');
$this->theme->AppendPlus($this,'jquery');
$this->theme->AppendPlus($this,'slides');
$auth = Zend_Auth::getInstance(); $auth = Zend_Auth::getInstance();
?> ?>
<div id="index"> <div id="index">
@ -101,16 +103,21 @@
<div id="rightPanel"> <div id="rightPanel">
<div id="feature"> <div id="feature">
<div class="alpha-shadow"> <div id="slides">
<div><img src="<?= $this->feature['imgurl']; ?>" alt="特色数据集" style="border-width:1px;border-style:solid;" /></div> <div class="slides_container">
</div> <?php
foreach($this->news as $k=>$v)
<div class="title"><?= $this->feature['title']; ?></div> {
<div class="description"> echo '<div class="slide">'.
<?= $this->feature['description']; ?> '<div class="thumb"><img src="'.$v['image'].'" /></div>'.
</div> '<div class="description"><h2><a href="'.$v['url'].'">'.$v['title'].'</a></h2>'.
<span class="more"><a href="/data/feature" >以往推荐</a></span> ''.$v['description'].'</div>'.
<span id="links"><a href="<?= $this->feature['detailurl']; ?>">详细</a></span> ''.
'</div>';
}
?>
</div>
</div>
</div> </div>
<div id="itemCd"> <div id="itemCd">
<div class="alpha-shadow" id="image"><img src="<?= $this->datasetcd['img']; ?>" /></div> <div class="alpha-shadow" id="image"><img src="<?= $this->datasetcd['img']; ?>" /></div>
@ -144,5 +151,16 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script>
var startSlide = 1;
$('#slides').slides({
preload: true,
preloadImage: 'images/loading.gif',
generatePagination: true,
play: 5000,
pause: 2500,
hoverPause: true,
start: startSlide
});
</script>

View File

@ -69,3 +69,9 @@ textarea {resize: none}
.input_arae{ margin:5px 0;} .input_arae{ margin:5px 0;}
.map_display_part{width:500px;height:300px;float:left;} .map_display_part{width:500px;height:300px;float:left;}
.auto-complete-elements{height:140px;position:absolute;z-index:999;background:#FFF;border:1px solid #ccc; padding:2px;}
.auto-complete-elements ul{height:120px;overflow-y:scroll;}
.auto-complete-elements ul li{line-height:18px; cursor:pointer;height:18px; overflow:hidden;border:1px solid #FFF;}
.auto-complete-elements ul li:hover{height:18px;line-height:18px; border:1px solid #dedede;}
.auto-complete-elements .close-btn{height:18px;line-height:18px;border:1px solid #ccc;cursor:pointer; text-align:center}

View File

@ -114,6 +114,7 @@ input:focus,textarea:focus {
-webkit-focus-ring-color:none; -webkit-focus-ring-color:none;
border-color:#c4c4c4; border-color:#c4c4c4;
background-color:#FFFFF0; background-color:#FFFFF0;
border-radius:3px;
} }
fieldset {border:0 none;border-top:1px solid #ddd;margin:10px 0;padding:10px 0;} fieldset {border:0 none;border-top:1px solid #ddd;margin:10px 0;padding:10px 0;}
legend {background:#fff;color:#93BB3A;font-weight:bold; padding:0 6px 0 0;} legend {background:#fff;color:#93BB3A;font-weight:bold; padding:0 6px 0 0;}

View File

@ -147,17 +147,23 @@ color:Green; text-decoration:none;
#dataLink ul{padding:5px 0;} #dataLink ul{padding:5px 0;}
#rightPanel #dataLink a{font-weight: bold;} #rightPanel #dataLink a{font-weight: bold;}
/*数据CD开始*/ /*新闻*/
#itemCd{ margin-top: 10px; border-bottom:1px dotted gray; overflow:hidden;} #itemCd{ margin-top: 10px; border-bottom:1px dotted gray; overflow:hidden;}
#itemCd img { margin-top:-5px;margin-left:-5px;width:100px;height:100px;border-width:1px;border-style:solid;}
#itemCd #image{float: left; width: 110px; height: 105px;}
#itemCd #title{font-size: 105%; font-weight: bold; font-family: Tahoma; }
#itemCd #filesize{color: Gray;font-size: 95%;}
#itemCd #descript{margin: 10px 2% 5px 0px; font-family: Verdana;}
#itemCd #descript #intro {font-style: italic;}
#itemCd #link {margin-bottom: 10px;}
#dataLink ul{display:inline;float:left;list-style-type: none;margin-top:-5px;} #dataLink ul{display:inline;float:left;list-style-type: none;margin-top:-5px;}
input{background:#ECF0F5;margin-bottom:6px;} input{background:#ECF0F5;margin-bottom:6px;}
dd,dt{margin:0;} dd,dt{margin:0;}
#dataLink dd {padding-bottom:5px;margin-left:5px;margin-top:-5px;} #dataLink dd {padding-bottom:5px;margin-left:5px;margin-top:-5px;}
#slides {overflow:hidden;}
#slides .slide{width:520px;}
#slides .slide { overflow:hidden;}
#slides .slide .thumb {float:left; overflow:hidden;}
#slides .slide .thumb img{max-height:150px;border:1px solid #CCC;padding:2px;margin:0 5px 0 0;}
#slides .slide .ctitle {float:left;overflow:hidden;}
#slides .slide .ctitle h2{font-weight:bold;display:block}
#slides .slide .description{float:left;}
#slides .pagination {}
#slides .pagination li{width:10px;height:16px;padding:2px;float:left;}
#slides .pagination li.current{background:#dedede;color:#FFF}

File diff suppressed because one or more lines are too long