-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PageRepository find by category #8
Comments
Thanks for the report, I'll investigate on this 👍 |
Any fix for this yet? I'm using this hack for now. |
@Gyvastis im solve overriding the repository namespace WebBundle\Repository;
use Doctrine\ORM\Tools\Pagination\Paginator;
use Orbitale\Bundle\CmsBundle\Repository\PageRepository;
use Orbitale\Bundle\CmsBundle\Entity\Category;
use Orbitale\Bundle\CmsBundle\Entity\Page;
/**
* PaginaRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class PaginaRepository extends PageRepository {
/**
* @param Category $category
* @param string $order
* @param string $orderBy
* @param int $page
* @param int $limit
*
* @return Paginator
*/
public function findByCategory( Category $category, $order, $orderBy, $page, $limit ): Paginator {
$qb = $this->createQueryBuilder( 'page' )
->where( 'page.category = :category' )
->andWhere( 'page.enabled = true' )
// ->orderBy( 'page.' . $orderBy, $order )
->setMaxResults( $limit )
->setFirstResult( $limit * ( $page - 1 ) )
->setParameter( 'category', $category );
return new Paginator( $qb->getQuery()->useResultCache( $this->cacheEnabled, $this->cacheTtl ) );
} and changing the repository mapping in entity * @ORM\Entity(repositoryClass="WebBundle\Repository\PaginaRepository")
*/
class Pagina extends BasePage implements AmpInterface { |
@matudelatower but you're messing up the order of page items inside a category page, no? |
@Gyvastis yes, but they always came in order by id by default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When find pages by category.
must be add
->andWhere('page.enabled = true')
like:The text was updated successfully, but these errors were encountered: