/** * Generates the URL for an FAQ. * * @param FaqModel $faq * * @return string|false */ private function generateUrl(FaqModel $faq) { /** @var PageModel $jumpTo */ if (!($category = $faq->getRelated('pid')) instanceof FaqCategoryModel || !($jumpTo = $category->getRelated('jumpTo')) instanceof PageModel) { return false; } /** @var Config $config */ $config = $this->framework->getAdapter(Config::class); return $jumpTo->getFrontendUrl(($config->get('useAutoItem') ? '/' : '/items/') . ($faq->alias ?: $faq->id)); }
/** * Create links and remember pages that have been processed * * @param FaqModel $objFaq * * @return string * * @throws \Exception */ protected function generateFaqLink($objFaq) { /** @var FaqCategoryModel $objCategory */ $objCategory = $objFaq->getRelated('pid'); $jumpTo = intval($objCategory->jumpTo); // A jumpTo page is not mandatory for FAQ categories (see #6226) but required for the FAQ list module if ($jumpTo < 1) { throw new \Exception("FAQ categories without redirect page cannot be used in an FAQ list"); } // Get the URL from the jumpTo page of the category if (!isset($this->arrTargets[$jumpTo])) { $this->arrTargets[$jumpTo] = ampersand(\Environment::get('request'), true); if ($jumpTo > 0 && ($objTarget = \PageModel::findByPk($jumpTo)) !== null) { /** @var PageModel $objTarget */ $this->arrTargets[$jumpTo] = ampersand($objTarget->getFrontendUrl(\Config::get('useAutoItem') ? '/%s' : '/items/%s')); } } return sprintf($this->arrTargets[$jumpTo], $objFaq->alias ?: $objFaq->id); }