给按数据集分类增加了分页功能
This commit is contained in:
parent
6a08ef80bc
commit
3cf6a50ff3
|
@ -312,7 +312,14 @@ class DataController extends Zend_Controller_Action
|
|||
$this->view->codename=(empty($row->name_zh)?$row->name:$row->name_zh);
|
||||
$sql='select m.* from metadata m,category c where m.id=c.id and c.code=? order by m.title';
|
||||
$state=$db->query($sql,array($code));
|
||||
$this->view->metadata = $state->fetchAll();
|
||||
$rows = $state->fetchAll();
|
||||
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(10);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
} else {
|
||||
//提供全部分类列表
|
||||
}
|
||||
|
|
|
@ -1,39 +1,51 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->data);
|
||||
$this->headTitle('分类浏览');
|
||||
if (!empty($this->codename)) $this->headTitle($this->codename);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headLink()->appendStylesheet('/css/metadata.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
|
||||
$this->breadcrumb('<a href="/data/category">分类浏览</a>');
|
||||
if (!empty($this->codename)) $this->breadcrumb($this->codename);
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<div id='tools'>
|
||||
<?= $this->partial('data/tools.phtml'); ?>
|
||||
</div>
|
||||
|
||||
<div id='leftnav'>
|
||||
<fieldset><legend>数据集类别</legend>
|
||||
<ul>
|
||||
<?php foreach($this->category as $cg) : ?>
|
||||
<li><a href='/data/category/code/<?php echo $cg['code']; ?>'><?php (empty($cg['name_zh']))?print($cg['name']):print($cg['name_zh']); ?></a><span class="note">(<?php echo $cg['count']; ?>)</span></li>
|
||||
<?php endforeach; ?>
|
||||
</ul></fieldset>
|
||||
</div>
|
||||
<div id='metacontent'>
|
||||
<?php if (!empty($this->metadata)) : ?>
|
||||
<h1>当前浏览分类:<?php echo $this->codename; ?></h1>
|
||||
<?php foreach($this->metadata as $md) : ?>
|
||||
<hr />
|
||||
<div class="mditem">
|
||||
<div class="thumb"><img src="/data/thumb/id/<?php echo $md['id'];?>" /></div>
|
||||
<h2><a href="/data/<?php echo $md['uuid']; ?>"><?php echo $this->escape($md['title']);?></a>
|
||||
</h2>
|
||||
<span><?php echo mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']);?></span>
|
||||
</div>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->data);
|
||||
$this->headTitle('分类浏览');
|
||||
if (!empty($this->codename)) $this->headTitle($this->codename);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headLink()->appendStylesheet('/css/metadata.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
|
||||
$this->breadcrumb('<a href="/data/category">分类浏览</a>');
|
||||
if (!empty($this->codename)) $this->breadcrumb($this->codename);
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<div id='tools'>
|
||||
<?= $this->partial('data/tools.phtml'); ?>
|
||||
</div>
|
||||
|
||||
<div id='leftnav'>
|
||||
<fieldset><legend>数据集类别</legend>
|
||||
<ul>
|
||||
<?php foreach($this->category as $cg) : ?>
|
||||
<li><a href='/data/category/code/<?php echo $cg['code']; ?>'><?php (empty($cg['name_zh']))?print($cg['name']):print($cg['name_zh']); ?></a><span class="note">(<?php echo $cg['count']; ?>)</span></li>
|
||||
<?php endforeach; ?>
|
||||
</ul></fieldset>
|
||||
</div>
|
||||
<div id='metacontent'>
|
||||
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<?php
|
||||
$i=0;
|
||||
foreach ($this->paginator as $item):
|
||||
$i++;
|
||||
if (mb_strlen($item['description'])>700)
|
||||
{
|
||||
$item['description'] = mb_substr($item['description'],0,400,'UTF-8').'...';
|
||||
}
|
||||
if($i%2==0) $style="style='background:#fafafa;'";
|
||||
else $style="";
|
||||
echo '<div class="mditem" '.$style.'>
|
||||
<div class="thumb"><img src="/data/thumb/id/'.$item['id'].'" /></div>
|
||||
<h2><a href="/data/'.$item['uuid'].'">'.$this->escape($item['title']).'</a>
|
||||
</h2>
|
||||
<p>'.$item['description'].'</p>
|
||||
</div>';
|
||||
endforeach;
|
||||
?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= $this->paginator; ?>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,26 @@
|
|||
<?php if ($this->pageCount): ?>
|
||||
<div class="paginationControl">
|
||||
<!-- Previous page link -->
|
||||
<?php if (isset($this->previous)): ?>
|
||||
<a href="<?= $this->url(array('page' => $this->previous)); ?>?<?php echo $_SERVER["QUERY_STRING"];?>">< Previous</a>
|
||||
<?php else: ?>
|
||||
<span class="disabled">< Previous</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Numbered page links -->
|
||||
<?php foreach ($this->pagesInRange as $page): ?>
|
||||
<?php if ($page != $this->current): ?>
|
||||
<a href="<?= $this->url(array('page' => $page)); ?>?<?php echo $_SERVER["QUERY_STRING"];?>"><?= $page; ?></a>
|
||||
<?php else: ?>
|
||||
<span class="current"><?= $page; ?></span>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<!-- Next page link -->
|
||||
<?php if (isset($this->next)): ?>
|
||||
<a href="<?= $this->url(array('page' => $this->next)); ?>?<?php echo $_SERVER["QUERY_STRING"];?>">Next ></a>
|
||||
<?php else: ?>
|
||||
<span class="disabled">Next ></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
Loading…
Reference in New Issue