本文整理汇总了PHP中NewsModel::findByAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsModel::findByAlias方法的具体用法?PHP NewsModel::findByAlias怎么用?PHP NewsModel::findByAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsModel
的用法示例。
在下文中一共展示了NewsModel::findByAlias方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCache
public function updateCache($item, $arrTerms, $strContent)
{
preg_match_all('#' . implode('|', $arrTerms['both']) . '#is', $strContent, $matches);
$matches = array_unique($matches[0]);
if (empty($matches)) {
return;
}
$News = \NewsModel::findByAlias($item);
$News->glossar = implode('|', $matches);
$News->save();
}
示例2: generateFrontendUrl
/**
* generateFrontendUrl Hook
* checks if the parameter for the generated URL is a news alias and rewrites the URL without its page alias
* @param array page data
* @param string URL parameters
* @param string current URL
*/
public function generateFrontendUrl($arrRow, $strParams, $strUrl)
{
// no params, no action
if (!$strParams) {
return $strUrl;
}
// check if param is a news alias
if (($objNews = \NewsModel::findByAlias(ltrim($strParams, '/'))) !== null) {
// build url using only the news alias
$strUrl = self::buildUrl($arrRow, $objNews->alias);
}
// return the url
return $strUrl;
}
示例3: checkAlias
/**
* Check the news alias for duplicates
*
* @param mixed $varValue
* @param DataContainer $dc
*
* @return string
*
* @throws Exception
*/
public function checkAlias($varValue, DataContainer $dc)
{
// check if there is a news article with the same alias
if (($objNews = \NewsModel::findByAlias($varValue)) !== null) {
// get the redirect page
if (($objTarget = \PageModel::findWithDetails($objNews->getRelated('pid')->jumpTo)) !== null) {
// get the page
$objPage = \PageModel::findWithDetails($dc->id);
// 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;
}
示例4: compile
protected function compile()
{
$objNews = \NewsModel::findByAlias(\Input::get('items'));
$this->Template->code = $objNews->vgwort_code;
}