给按数据集分类增加了分页功能
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);
|
$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';
|
$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));
|
$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 {
|
} else {
|
||||||
//提供全部分类列表
|
//提供全部分类列表
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,51 @@
|
||||||
<?php
|
<?php
|
||||||
$this->headTitle($this->config->title->site);
|
$this->headTitle($this->config->title->site);
|
||||||
$this->headTitle($this->config->title->data);
|
$this->headTitle($this->config->title->data);
|
||||||
$this->headTitle('分类浏览');
|
$this->headTitle('分类浏览');
|
||||||
if (!empty($this->codename)) $this->headTitle($this->codename);
|
if (!empty($this->codename)) $this->headTitle($this->codename);
|
||||||
$this->headTitle()->setSeparator(' - ');
|
$this->headTitle()->setSeparator(' - ');
|
||||||
$this->headLink()->appendStylesheet('/css/metadata.css');
|
$this->headLink()->appendStylesheet('/css/metadata.css');
|
||||||
$this->breadcrumb('<a href="/">首页</a>');
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
|
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
|
||||||
$this->breadcrumb('<a href="/data/category">分类浏览</a>');
|
$this->breadcrumb('<a href="/data/category">分类浏览</a>');
|
||||||
if (!empty($this->codename)) $this->breadcrumb($this->codename);
|
if (!empty($this->codename)) $this->breadcrumb($this->codename);
|
||||||
$this->breadcrumb()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
?>
|
?>
|
||||||
<div id='tools'>
|
<div id='tools'>
|
||||||
<?= $this->partial('data/tools.phtml'); ?>
|
<?= $this->partial('data/tools.phtml'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id='leftnav'>
|
<div id='leftnav'>
|
||||||
<fieldset><legend>数据集类别</legend>
|
<fieldset><legend>数据集类别</legend>
|
||||||
<ul>
|
<ul>
|
||||||
<?php foreach($this->category as $cg) : ?>
|
<?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>
|
<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; ?>
|
<?php endforeach; ?>
|
||||||
</ul></fieldset>
|
</ul></fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div id='metacontent'>
|
<div id='metacontent'>
|
||||||
<?php if (!empty($this->metadata)) : ?>
|
|
||||||
<h1>当前浏览分类:<?php echo $this->codename; ?></h1>
|
<?php if (count($this->paginator)): ?>
|
||||||
<?php foreach($this->metadata as $md) : ?>
|
<?php
|
||||||
<hr />
|
$i=0;
|
||||||
<div class="mditem">
|
foreach ($this->paginator as $item):
|
||||||
<div class="thumb"><img src="/data/thumb/id/<?php echo $md['id'];?>" /></div>
|
$i++;
|
||||||
<h2><a href="/data/<?php echo $md['uuid']; ?>"><?php echo $this->escape($md['title']);?></a>
|
if (mb_strlen($item['description'])>700)
|
||||||
</h2>
|
{
|
||||||
<span><?php echo mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']);?></span>
|
$item['description'] = mb_substr($item['description'],0,400,'UTF-8').'...';
|
||||||
</div>
|
}
|
||||||
<?php endforeach;
|
if($i%2==0) $style="style='background:#fafafa;'";
|
||||||
endif; ?>
|
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>
|
</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