本文整理汇总了PHP中PageModel::findByAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::findByAlias方法的具体用法?PHP PageModel::findByAlias怎么用?PHP PageModel::findByAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel::findByAlias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkAlias
/**
* Check the news alias for duplicates
*
* @param mixed $varValue
* @param DataContainer $dc
*
* @return string
*
* @throws Exception
*/
public function checkAlias($varValue, DataContainer $dc)
{
// get the news archive first
if (($objArchive = \NewsArchiveModel::findById($dc->activeRecord->pid)) !== null) {
// get the redirect page
if (($objTarget = \PageModel::findById($objArchive->jumpTo)) !== null) {
// check if there is a page with the same alias
if (($objPage = \PageModel::findByAlias($varValue)) !== null) {
// load the details
$objTarget->current()->loadDetails();
$objPage->current()->loadDetails();
// check if page is on the same domain and language
if ($objPage->domain == $objTarget->domain && (\Config::get('addLanguageToUrl') && $objPage->rootLanguage == $objTarget->rootLanguage)) {
// append id
$varValue .= '-' . $dc->id;
}
}
}
}
// return the alias
return $varValue;
}
示例2: validate
private function validate($name, $domain)
{
// check if a page exists
if (!\Config::get('urlSuffix') && ($objPages = \PageModel::findByAlias($name)) !== null) {
// check if short url has a domain
if ($domain > 0) {
$valid = true;
while ($objPages->next()) {
// load page details
$objPages->current()->loadDetails();
// if one of the found pages is within the same domain, do not allow it
if ($objPages->rootId == $domain) {
$valid = false;
break;
}
}
if ($valid) {
return;
}
}
// otherwise throw exception
throw new Exception(sprintf($GLOBALS['TL_LANG']['tl_short_urls']['pageExists'], $name));
}
}