Answer the question
In order to leave comments, you need to log in
Routing. How to remove nesting levels?
there are links like
site.loc/catalog/ees/catalogGroup-31177
site.loc/catalog/bbs/catalogGroup-31232/catalogGroup-31
site.loc/catalog/bvs/catalogGroup-3232/catalogGrou...
here is the route for these pages :
_auto:
pattern: /{url}
defaults: { _controller: SiteRsrSecurityBundle:ContentTypes:loadUrlPage }
requirements:
url: ".+"
public function catalogGroupType(Page $page)
{
$childGroups = $this->getContentService()->getListPages($page->getId(), new PageFilter('catalogGroup'));
echo $page->getId();
if ( /*count($this->data['navPath'][0]) and */ count($childGroups)) {
$firstPage = current($childGroups);
// echo count($this->data['navPath'][0]);
return $this->redirect($this->convertUrl($firstPage->getUrl()));
}
$this->data['groups'] = array();
if (count($childGroups)) {
$this->data['groups'] = $childGroups;
} else {
$parentPage = end($this->data['navPath'][0]);
if ($parentPage)
$this->data['groups'] = $this->getContentService()->getListPages($parentPage->getId(), new PageFilter('catalogGroup'));
}
$startPage = $this->getRequest()->get('page', 1);
$idsChildGroup = array_keys($childGroups);
//Третий уровень
if (count($idsChildGroup)) {
$subChildGroups = $this->getContentService()->getListPages($idsChildGroup, new PageFilter('catalogGroup'));
$idsChildGroup = array_merge($idsChildGroup, array_keys($subChildGroups));
}
$idsGroup = array_merge(array($page->getId()), $idsChildGroup);
try {
$productsQuery = $this->getContentService()->getListPagesQuery($idsGroup, new PageFilter('product', 'p.price, p.title'));
$this->data['products'] = $this->getPaginator()->paginate($productsQuery, $startPage, 15);
} catch (\Exception $exc) {
return $this->pageNotFound();
}
return $this->renderPage('PageType:catalog_group.html.twig');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question