Suche über ID...
Beispiel für Artikel:
PHP-Code:
/**
* Add articles to ret-array
* @param str $s
*/
protected function addArticles($s)
{
$queryAddon = $selectAddon = '';
if(!$this->User->isAdmin)
{
// Get all allowed pages for the current user
$pagemounts = array();
foreach ($this->User->pagemounts as $root)
{
$pagemounts[] = $root;
$pagemounts = array_merge($pagemounts, $this->Database->getChildRecords($root, 'tl_page', true));
}
$pagemounts = array_unique($pagemounts);
$queryAddon = 'LEFT JOIN tl_page AS p ON (a.pid = p.id)';
$selectAddon = ',includeChmod,p.pid,chmod,cuser,cgroup';
}
## ab hier ##
$whereAddon = 'title LIKE ';
$executeAddon = '%'.$s.'%';
// search Id
if(is_int(((int)$s)) && !empty($s))
{
$whereAddon = 'id = ';
$executeAddon = $s;
}
$objArticle = $this->Database->prepare('SELECT a.id,a.title,a.published,a.start,a.stop,a.pid AS pageId
'.$selectAddon.'
FROM tl_article AS a
'.$queryAddon.'
WHERE a.'.$whereAddon.' ? ORDER BY a.title')
->limit($this->limitEach)
->execute($executeAddon);
while($objArticle->next())
{
// check rights
if (!$this->User->isAdmin)
{
if(!in_array($objArticle->pageId, $pagemounts)) continue;
if(!$this->User->isAllowed(4, $objArticle->row())) continue;
}
$time = time();
$published = ($objArticle->published && ($objArticle->start == '' || $objArticle->start < $time) && ($objArticle->stop == '' || $objArticle->stop > $time));
$this->ret[] = array
(
'type' => 'article',
'name' => 'a:'.$objArticle->title,
'url' => $this->base.'main.php?do=article&table=tl_content&id='.$objArticle->id,
'image' => $this->generateImage('articles'.($published ? '' : '_').'.gif')
);
}
}
Lesezeichen