本文整理汇总了PHP中NewsModel::findByIdOrAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsModel::findByIdOrAlias方法的具体用法?PHP NewsModel::findByIdOrAlias怎么用?PHP NewsModel::findByIdOrAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsModel
的用法示例。
在下文中一共展示了NewsModel::findByIdOrAlias方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addDataForContent
/**
* @param AddDataForContentEvent $event
*/
public function addDataForContent(AddDataForContentEvent $event)
{
if (!$event->getModule() instanceof \ModuleNewsReader && \Input::get('auto_item')) {
return;
}
$alias = \Input::get('auto_item');
$model = \NewsModel::findByIdOrAlias($alias);
if (!$model) {
return;
}
global $objPage;
//TODO test url by multi domains
$event->setUrl(\Controller::generateFrontendUrl($objPage->row(), '/' . $model->alias, \Config::get('addLanguageToUrl'), $objPage->domain));
$event->setTemplate('search_content_news');
$event->setData($model);
}
示例2: replace
//.........这里部分代码省略.........
}
break;
// Link
// Link
case 'link':
case 'link_open':
case 'link_url':
case 'link_title':
case 'link_target':
case 'link_name':
$strTarget = null;
// Back link
if ($elements[1] == 'back') {
$strUrl = 'javascript:history.go(-1)';
$strTitle = $GLOBALS['TL_LANG']['MSC']['goBack'];
// No language files if the page is cached
if (!strlen($strTitle)) {
$strTitle = 'Go back';
}
$strName = $strTitle;
} elseif (strncmp($elements[1], 'http://', 7) === 0 || strncmp($elements[1], 'https://', 8) === 0) {
$strUrl = $elements[1];
$strTitle = $elements[1];
$strName = str_replace(array('http://', 'https://'), '', $elements[1]);
} else {
// User login page
if ($elements[1] == 'login') {
if (!FE_USER_LOGGED_IN) {
break;
}
$this->import('FrontendUser', 'User');
$elements[1] = $this->User->loginPage;
}
$objNextPage = \PageModel::findByIdOrAlias($elements[1]);
if ($objNextPage === null) {
break;
}
// Page type specific settings (thanks to Andreas Schempp)
switch ($objNextPage->type) {
case 'redirect':
$strUrl = $this->replaceInsertTags($objNextPage->url);
// see #6765
if (strncasecmp($strUrl, 'mailto:', 7) === 0) {
$strUrl = \StringUtil::encodeEmail($strUrl);
}
break;
case 'forward':
if ($objNextPage->jumpTo) {
/** @var \PageModel $objNext */
$objNext = $objNextPage->getRelated('jumpTo');
} else {
$objNext = \PageModel::findFirstPublishedRegularByPid($objNextPage->id);
}
if ($objNext !== null) {
$strForceLang = null;
$objNext->loadDetails();
// Check the target page language (see #4706)
if (\Config::get('addLanguageToUrl')) {
$strForceLang = $objNext->language;
}
$strUrl = $this->generateFrontendUrl($objNext->row(), null, $strForceLang, true);
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
示例3: replaceInsertTags
//.........这里部分代码省略.........
}
// Convert special characters (see #1890)
$arrCache[$strTag] = specialchars($arrCache[$strTag]);
}
break;
// Link
// Link
case 'link':
case 'link_open':
case 'link_url':
case 'link_title':
// Back link
if ($elements[1] == 'back') {
$strUrl = 'javascript:history.go(-1)';
$strTitle = $GLOBALS['TL_LANG']['MSC']['goBack'];
// No language files if the page is cached
if (!strlen($strTitle)) {
$strTitle = 'Go back';
}
$strName = $strTitle;
} elseif (strncmp($elements[1], 'http://', 7) === 0 || strncmp($elements[1], 'https://', 8) === 0) {
$strUrl = $elements[1];
$strTitle = $elements[1];
$strName = str_replace(array('http://', 'https://'), '', $elements[1]);
} else {
// User login page
if ($elements[1] == 'login') {
if (!FE_USER_LOGGED_IN) {
break;
}
$this->import('FrontendUser', 'User');
$elements[1] = $this->User->loginPage;
}
$objNextPage = \PageModel::findByIdOrAlias($elements[1]);
if ($objNextPage === null) {
break;
}
// Page type specific settings (thanks to Andreas Schempp)
switch ($objNextPage->type) {
case 'redirect':
$strUrl = $objNextPage->url;
if (strncasecmp($strUrl, 'mailto:', 7) === 0) {
$strUrl = \String::encodeEmail($strUrl);
}
break;
case 'forward':
if (($objTarget = $objNextPage->getRelated('jumpTo')) !== null) {
$strUrl = $this->generateFrontendUrl($objTarget->row());
break;
} elseif (($objTarget = \PageModel::findFirstPublishedRegularByPid($objNextPage->id)) !== null) {
if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
$objTarget = $this->getPageDetails($objTarget);
// see #3983
$strUrl = $this->generateFrontendUrl($objTarget->row(), null, $objTarget->language);
} else {
$strUrl = $this->generateFrontendUrl($objTarget->row());
}
break;
}
// DO NOT ADD A break; STATEMENT
// DO NOT ADD A break; STATEMENT
default:
if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
$objNextPage = $this->getPageDetails($objNextPage);
// see #3983
$strUrl = $this->generateFrontendUrl($objNextPage->row(), null, $objNextPage->language);
示例4: compile
/**
* Generate the module
*/
protected function compile()
{
$limit = null;
$offset = intval($this->skipFirst);
// Maximum number of items
if ($this->numberOfItems > 0) {
$limit = $this->numberOfItems;
}
// Handle featured news
if ($this->news_featured == 'featured') {
$blnFeatured = true;
} elseif ($this->news_featured == 'unfeatured') {
$blnFeatured = false;
} else {
$blnFeatured = null;
}
$this->Template->articles = array();
$this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyList'];
$objCurrArticle = \NewsModel::findByIdOrAlias(\Input::get('items'));
if (!is_object($objCurrArticle)) {
return;
}
//nur das Archiv von der aktuell angezeigten News ist relevant
$this->news_archives = array($objCurrArticle->pid);
// Get the total number of items
$intTotal = $this->countItems($this->news_archives, $blnFeatured) - 1;
if ($intTotal < 1) {
return;
}
$total = $intTotal - $offset;
// Split the results
if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage)) {
// Adjust the overall limit
if (isset($limit)) {
$total = min($limit, $total);
}
// Get the current page
$id = 'page_n' . $this->id;
$page = \Input::get($id) !== null ? \Input::get($id) : 1;
// Do not index or cache the page if the page number is outside the range
if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
/** @var \PageModel $objPage */
global $objPage;
/** @var \PageError404 $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($objPage->id);
}
// Set limit and offset
$limit = $this->perPage;
$offset += (max($page, 1) - 1) * $this->perPage;
$skip = intval($this->skipFirst);
// Overall limit
if ($offset + $limit > $total + $skip) {
$limit = $total + $skip - $offset;
}
// Add the pagination menu
$objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
$this->Template->pagination = $objPagination->generate("\n ");
}
$objArticles = $this->fetchOtherItems($this->news_archives, $objCurrArticle->id, $blnFeatured, $limit ?: 0, $offset);
// Add the articles
if ($objArticles !== null) {
$this->Template->articles = $this->parseArticles($objArticles);
}
$this->Template->archives = $this->news_archives;
}