public static findPublishedByPidAndColumn ( integer $intPid, string $strColumn, array $arrOptions = [] ) : |
||
$intPid | integer | The page ID |
$strColumn | string | The column name |
$arrOptions | array | An optional options array |
Результат | A collection of models or null if there are no articles in the given column |
public static function findPublishedByPidAndColumn($intPid, $strColumn, array $arrOptions = array())
{
$t = static::$strTable;
$arrColumns = array("{$t}.pid=? AND {$t}.inColumn=?");
$arrValues = array($intPid, $strColumn);
if (isset($arrOptions['ignoreFePreview']) || !BE_USER_LOGGED_IN) {
$time = \Date::floorToMinute();
$arrColumns[] = "({$t}.start='' OR {$t}.start<='{$time}') AND ({$t}.stop='' OR {$t}.stop>'" . ($time + 60) . "') AND {$t}.published='1'";
}
if (!isset($arrOptions['order'])) {
$arrOptions['order'] = "{$t}.sorting";
}
return static::findBy($arrColumns, $arrValues, $arrOptions);
}
/** * Generate the module */ protected function compile() { /** @var PageModel $objPage */ global $objPage; if (!strlen($this->inColumn)) { $this->inColumn = 'main'; } $intCount = 0; $articles = array(); $id = $objPage->id; $this->Template->request = \Environment::get('request'); // Show the articles of a different page if ($this->defineRoot && $this->rootPage > 0) { if (($objTarget = $this->objModel->getRelated('rootPage')) !== null) { $id = $objTarget->id; $this->Template->request = $this->generateFrontendUrl($objTarget->row()); } } // Get published articles $objArticles = \ArticleModel::findPublishedByPidAndColumn($id, $this->inColumn); if ($objArticles === null) { return; } while ($objArticles->next()) { // Skip first article if (++$intCount <= intval($this->skipFirst)) { continue; } $cssID = deserialize($objArticles->cssID, true); $articles[] = array('link' => $objArticles->title, 'title' => specialchars($objArticles->title), 'id' => $cssID[0] ?: 'article-' . $objArticles->id, 'articleId' => $objArticles->id); } $this->Template->articles = $articles; }