src/PHPDish/Bundle/PostBundle/Controller/CategoryController.php
public function viewAction($slug, Request $request)
    {
        $category = $this->getCategoryManager()->findCategoryBySlug($slug);
        $criteria = Criteria::create()->where(Criteria::expr()->eq('category', $category->getId()))
            ->andWhere(Criteria::expr()->eq('enabled', true));
        if ($request->query->get('orderby') === 'hot') {
            $criteria->orderBy([
                'viewCount' => 'desc',
                'createdAt' => 'desc',
            ]);
        } else {
            $criteria->orderBy([
                'createdAt' => 'desc',
            ]);
        }
        $posts = $this->getPostManager()->findPostsPager($criteria, $request->query->getInt('page', 1));

        return $this->render($this->configuration->getTemplate('Category:view.html.twig'), [
            'category' => $category,
            'posts' => $posts,
        ]);
    }
public function viewAction($slug, Request $request)
    {
        $category = $this->getCategoryManager()->findCategoryBySlug($slug);
        $criteria = Criteria::create()->where(Criteria::expr()->eq('category', $category->getId()))
            ->andWhere(Criteria::expr()->eq('enabled', true));
        if ($request->query->get('orderby') === 'hot') {
            $criteria->orderBy([
                'viewCount' => 'desc',
                'createdAt' => 'desc',
            ]);
        } else {
            $criteria->orderBy([
                'createdAt' => 'desc',
            ]);
        }
        $posts = $this->getPostManager()->findPostsPager($criteria, $request->query->getInt('page', 1));

        return $this->render($this->configuration->getTemplate('Category:view.html.twig'), [
            'category' => $category,
            'posts' => $posts,
        ]);
    }
专栏详情.

@Route("/categories/{slug}", name="category_view")

@param string  $slug
@param Request $request

@return Response