[TYPO3-ttnews] showRelatedNewsByCategory = 1 => sorted by category?
Martin Holtz
typo3 at martinholtz.de
Tue Jul 17 14:22:45 CEST 2007
Hi,
i use
showRelatedNewsByCategory=1
and i want to show the news divided into categorys.
related news from category a:
-> item1
-> item2
-> item3
related news from category b:
-> item4
-> item5
related News from category c:
-> item6
i thougt i could use
orderBy = category
but the field "category" only counts how many categorys are related.
At this time, i was only able to implement this, with patching the function
displayList().
But i think, i am wrong and there should be an better way to do that?
Any hint?
thanks,
martin
P.S.:
thats, what i have done
if ($this->config['orderBy']) {
if (strtoupper($this->config['orderBy']) == 'RANDOM') {
$selectConf['orderBy'] = 'RAND()';
// this statement is new:
// now, we have the first category which is assigned available
// and we are able to sort by the category
} elseif ($this->config['orderBy'] == 'category') {
$selectConf['leftjoin'] = 'tt_news_cat_mm ON tt_news.uid =
tt_news_cat_mm.uid_local';
$selectConf['selectFields'] = 'DISTINCT tt_news.uid,tt_news.*,
tt_news_cat_mm.uid_foreign';
$selectConf['orderBy'] = ' tt_news_cat_mm.sorting asc,
tt_news_cat_mm.uid_foreign ';
$selectConf['groupBy'] = 'tt_news_cat_mm.uid_local';
} else {
$selectConf['orderBy'] = $this->config['orderBy'] .
($this->config['ascDesc']?' ' . $this->config['ascDesc']:'');
}
} else {
$selectConf['orderBy'] = 'datetime DESC';
}
More information about the TYPO3-project-tt-news
mailing list