gpt4 book ai didi

zend-framework - Zend_Paginator : no page number on links on a page with no page number specified by the URL

转载 作者:行者123 更新时间:2023-12-02 02:32:05 29 4
gpt4 key购买 nike

如果不将/1 粘贴到 url 上,是否可以改变 Zend_Paginator 来处理 URL?当前用户转到/aaron/studio。然后用户应该点击页面并开始访问 URL,例如:/aaron/studio/2

我有这条规则:

$router->addRoute('studios/page',   new Zend_Controller_Router_Route(':id/studio/:page',array('module' => 'default', 'controller' => 'studio', 'action' => 'view')));

如果我转到/aaron/studio/2,Paginator 会正确链接到其他页面,如果我转到/aaron/studio,它不会链接到其他页面,只会链接到该页面。

我需要以某种方式让分页器知道它的位置,即使 URL 中没有页面。

如果有帮助,这是我的 Controller 代码:

      $page   = $this->_getParam('page', 1);
$from = ($page * $this->clips_per_page) - $this->clips_per_page;
$count = Model_Clip::load_by_type(array('type' => 'studio_id', 'values' => $object->id, 'to' => 0, 'to' => COUNT_HIGH, 'count' => 1, 'order' => 'd.views DESC'));
$paginator = Zend_Paginator::factory($count);
$paginator->setItemCountPerPage($this->clips_per_page);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(25);
$this->view->paginator = $paginator;

编辑,根据要求,这里是我的观点:

<?php if (count($this->paginator) && $this->paginator->count() > 1): ?>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml', array('translate' => $this->translate)); ?>
<?php endif; ?>

和部分

<div class="pagination-control" style="width: auto; text-align: center; margin: 0 auto">
<div style="width: auto;">

<!-- First page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url(array('page' => $this->first)); ?>">Start</a> |
<?php else: ?>
<!-- <span class="disabled">Start |</span> -->
<?php endif; ?>

<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url(array('page' => $this->previous)); ?>"> 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="<?php echo $this->url(array('page' => $page)); ?>"><?php echo $page; ?></a>
<?php else: ?>
<span class="chosen"><?php echo $page; ?></span>
<?php endif; ?>
<?php endforeach; ?>

<!-- Next page link -->
<?php if (isset($this->next)): ?>
| <a href="<?php echo $this->url(array('page' => $this->next)); ?>">Next </a> |
<?php else: ?>
<!-- <span class="disabled">| Next |</span> -->
<?php endif; ?>

<!-- Last page link -->
<?php if (isset($this->next)): ?>
<a href="<?php echo $this->url(array('page' => $this->last)); ?>">End</a>
<?php else: ?>
<!-- <span class="disabled">End</span> -->
<?php endif; ?>
<p>
&nbsp; Page <?php echo $this->current; ?> of <?php echo $this->last; ?>
</p>

</div>
<p class="clear"></p>
</div>

最佳答案

我也遇到了同样的问题,后来才发现是路由的问题。首先我指定了这样的路线:

$router->addRoute(
'projects',
new Zend_Controller_Router_Route('/:lang/projects/:category/',
array('lang' => 'en',
'module' => 'index',
'controller' =>'projects',
'action' =>'index'
)
)
);

所以分页器在生成链接时没有打印页码,当我更改路由并放置 :page var 时分页器工作。最终的路线是:

$router->addRoute(
'projects',
new Zend_Controller_Router_Route('/:lang/projects/:category/:page',
array('lang' => 'en',
'module' => 'index',
'controller' =>'projects',
'action' =>'index',
'page' => 1
)
)
);

关于zend-framework - Zend_Paginator : no page number on links on a page with no page number specified by the URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3365148/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com