class CubistPageController extends CubistFrontController
{
- public function index(Request $request, $slug = 'home')
+ public function index(Request $request, $id)
{
$class = CMSPage::getPageClass();
/** @var CMSPage $page */
- $page = Menu::getNavigation()->findOneBy('slug', $slug)->getEntity();
+ $page = Menu::getNavigation()->findOneById($id)->getEntity();
if (!$page) {
$this->_404();
$path = 'home';
}
$nav = Menu::getNavigation();
- $item = $nav->findItemWithURL($path);
+ $item = $nav->findItemWithURL($path,true);
+
if (null === $item) {
$redirectItem = $nav->findOneWithAlias($path);
if (null !== $redirectItem) {
return null;
}
- public function findItemWithURL($href)
+ public function findItemWithURL($href, $restrictToNavigable = true)
{
foreach ($this->findAllBy('href', $href) as $item) {
if (!($item instanceof PageItem)) {
return $item;
}
/** @var $item PageItem */
- if (stripos($item->getTemplate(), 'redirection') !== false) {
+ if ($restrictToNavigable && !$item->isNavigable()) {
continue;
}
return $item;
/** @var PageItem $template */
if (null !== $page->getPage()) {
$template = $page->getPage()->getUsedTemplate();
- if ($template instanceof Redirection || $template instanceof Navigation) {
+ if (!$template->isNavigable()) {
continue;
}
}
public function getController(): array
{
if (!$this->_controller) {
- return ['controller' => 'PageController', 'action' => 'index', 'params' => ['slug' => $this->getSlug()]];
+ return ['controller' => 'PageController', 'action' => 'index', 'params' => ['id' => $this->getId()]];
}
return parent::getController();
}
class Navigation extends TemplateAbstract
{
protected $_virtual = true;
+ protected $_navigable = false;
public function init()
{
class Redirection extends TemplateAbstract
{
+
+ protected $_navigable = false;
+
public function init()
{
parent::init();
protected $defaultFieldAttributes = [];
protected $_fields = [];
-
+ /**
+ * @var bool
+ */
protected $_virtual = false;
+ /**
+ * @var bool
+ */
+ protected $_navigable = true;
public function __construct()
{
return $this->_virtual;
}
+ /**
+ * @return bool
+ */
+ public function isNavigable()
+ {
+ return $this->_navigable;
+ }
+
/**
* @param $data array Current page data for the view