抛出下一个异常: Zend\View\Renderer\PhpRenderer::render: Unable to render template "./opt/lampp/htdocs/guest-book/module/Records/view/records/records/paginator"; 解析器无法解析为文件。我试图在不同的目录中以不同的方式设置路径,但仍然无法正常工作
控制器:
class RecordsController extends AbstractActionController
{
protected $recordsTable;
public function indexAction()
{
$field = (string) $this->params()->fromRoute('field', 'date');
$order = (string) $this->params()->fromRoute('order', 'desc');
$array = array('records' =>$this->getRecordsTable()->getByOrder($field, $order),);
$paginator = new Paginator\Paginator(new Paginator\Adapter\ArrayAdapter($array));
$paginator->setCurrentPageNumber($this->params()->fromRoute('page', 1));
$paginator->setPageRange(3);
$paginator->setDefaultScrollingStyle('Sliding');
print_r($paginator);
$pag = new Helper\PaginationControl();
$pag::setDefaultViewPartial('opt/lampp/htdocs/guest-book/module/Records/view/records/records/paginator.phtml', 'default');
$vm = new ViewModel($array);
$vm->setVariable('paginator', $paginator);
return $vm;
}
记录表:
class RecordsTable
{
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
{
$this->tableGateway = $tableGateway;
}
public function getByOrder($field, $order)
{
$this->field = $field;
$this->order = $order;
$resultSet = $this->tableGateway->select(function (Select $select) {
$select->order($this->field.' '.$this->order);
});
return $resultSet;
}
在视图中:
<?php if (count($this->paginator)): ?>
<ul>
<?php foreach ($this->paginator as $item): ?>
要不就:
<? echo $this->paginator;?>
还是有问题。
万分感谢!