0

I created a page testPage and use $pageExist = $this->getUrl('testPage') ?> so i could render an a block if it exist like so if ($pageExist)

BUT when i go from amdin panel and set page from enabled to disabled, clear cache, the $pageExist is till true, or what i assume, since if statement is getting fired even tho you can not enter that URL

1
  • What do you really want to achieve with that ? I'm not getting what you want with : so i could render an a block if it exist
    – Claims
    Commented Oct 13, 2021 at 13:45

1 Answer 1

0

getUrl() is just a return address Magento understands no matter the particular page exists or not. you should debug how magento redirects to 404 when no page found.

Check File : \Magento\Framework\App\FrontController

 public function dispatch(RequestInterface $request)
    {
        \Magento\Framework\Profiler::start('routers_match');
        $this->validatedRequest = false;
        $routingCycleCounter = 0;
        $result = null;
        while (!$request->isDispatched() && $routingCycleCounter++ < 100) {
            /** @var \Magento\Framework\App\RouterInterface $router */
            foreach ($this->_routerList as $router) {
                try {
                    $actionInstance = $router->match($request);
                    if ($actionInstance) {
                        $result = $this->processRequest(
                            $request,
                            $actionInstance
                        );
                        break;
                    }
                } catch (\Magento\Framework\Exception\NotFoundException $e) {
                    $request->initForward();
                    $request->setActionName('noroute');
                    $request->setDispatched(false);
                    break;
                }
            }
        }
        \Magento\Framework\Profiler::stop('routers_match');
        if ($routingCycleCounter > 100) {
            throw new \LogicException('Front controller reached 100 router match iterations');
        }
        return $result;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.