public function getTargetPage(NewsCategoryModel $category)
    {
        $pageId = $category->jumpTo;

        // Inherit the page from parent if there is none set
        if (!$pageId) {
            $pid = $category->pid;

            do {
                /** @var NewsCategoryModel $parent */
                $parent = $category->findByPk($pid);

                if (null !== $parent) {
                    $pid = $parent->pid;
                    $pageId = $parent->jumpTo;
                }
            } while ($pid && !$pageId);
        }

        // Get the page model
        if ($pageId) {
            /** @var PageModel $pageAdapter */
            $pageAdapter = $this->framework->getAdapter(PageModel::class);

            return $pageAdapter->findPublishedById($pageId);
        }

        return null;
    }
public function getTargetPage(NewsCategoryModel $category)
    {
        $pageId = $category->jumpTo;

        // Inherit the page from parent if there is none set
        if (!$pageId) {
            $pid = $category->pid;

            do {
                /** @var NewsCategoryModel $parent */
                $parent = $category->findByPk($pid);

                if (null !== $parent) {
                    $pid = $parent->pid;
                    $pageId = $parent->jumpTo;
                }
            } while ($pid && !$pageId);
        }

        // Get the page model
        if ($pageId) {
            /** @var PageModel $pageAdapter */
            $pageAdapter = $this->framework->getAdapter(PageModel::class);

            return $pageAdapter->findPublishedById($pageId);
        }

        return null;
    }
public function getTargetPage ( NewsCategoryModel $ category ) { $ pageId = $ category -> jumpTo ; // Inherit the page from parent if there is none set if ( ! $ pageId ) { $ pid = $ category -> pid ; do { /** @var NewsCategoryModel $parent */ $ parent = $ category -> findByPk ( $ pid ) ; if ( null !== $ parent ) { $ pid = $ parent -> pid ; $ pageId = $ parent -> jumpTo ; } } while ( $ pid && ! $ pageId ) ; } // Get the page model if ( $ pageId ) { /** @var PageModel $pageAdapter */ $ pageAdapter = $ this -> framework -> getAdapter ( PageModel :: class ) ; return $ pageAdapter -> findPublishedById ( $ pageId ) ; } return null ; }
Get the category target page.

@param NewsCategoryModel $category

@return PageModel|null
Get the category target page .