我正在使用Symfony2.3作爲我的項目和分頁使用KNP paginator Bundle。 我想知道如何在頁面中實現rel = prev和rel = next?如何在Symfony2.3分頁之後實現rel = prev和rel =?
我的控制器:
<?php
namespace XXX\ABCBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Session\Session;
use Doctrine\ORM\EntityManager;
/**
* author Siddharth Singh ([email protected])
*/
class ArcController extends Controller {
/**
* @Route("/arch", name="_arch")
* @Template()
*/
public function indexAction() {
$em = $this->getDoctrine()->getEntityManager();
$AArtEntity = $em->getRepository('XXXABCBundle:Arc')->findAll(array('updated'=>'DESC'));
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$AArtEntity, $this->get('request')->query->get('page', 1)/* page number */, 10/* limit per page */
);
return array('article' => $pagination);
}
}
嫩枝文件: -
{% extends 'XXXABCBundle::layout.html.twig' %}
{% block body %}
{% for artic in article %}
<div class="txt">
<p>{{artic.description|striptags|titletruncate(250)}}</p>
</div>
{% endfor %}
<div class="arcive_Paging">
<ul class="ul_paging">
<span class="acitve">{{ knp_pagination_render(article) }}</span>
</ul>
</div>
{% endblock %}
謝謝!
感謝的答案,但我有點迷惑你能給我一些些例子嗎? – Sid
當然,我更新了我的答案。 –
很多非常感謝,但我希望rel = prev和rel = next示例?你能幫我解決嗎? – Sid