Skip to content

Commit

Permalink
Fixed displaying news list in the back end
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jan 17, 2022
1 parent 6dfd95b commit 9314351
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Contao\ArticleModel;
use Contao\CalendarEventsModel;
use Contao\CalendarModel;
use Contao\Config;
use Contao\Date;
use Contao\FaqCategoryModel;
use Contao\FaqModel;
use Contao\Input;
Expand Down Expand Up @@ -117,6 +119,10 @@ public function onNewsChildRecords(array $args, $previousResult = null)
$row = $args[0];
$label = (string) $previousResult;

if (empty($label)) {
$label = '<div class="tl_content_left">' . $row['headline'] . ' <span style="color:#999;padding-left:3px">[' . Date::parse(Config::get('datimFormat'), $row['date']) . ']</span></div>';

This comment has been minimized.

Copy link
@fritzmg

fritzmg Jan 17, 2022

Contributor

This will ignore the configured label of the DCA. It would be better to implement either a child_record_callback or a label_callback depending on the Contao version (via a loadDataContainer hook for instance).

This comment has been minimized.

Copy link
@aschempp

aschempp Jan 17, 2022

Author Member

I did look into that, but unfortunately I do not get the DataContainer object in a child_record_callback and cannot call DataContainer::generateRowLabel() from it. This might just be a quickfix, would you think we can add the DC as a callback argument?

This comment has been minimized.

Copy link
@fritzmg

fritzmg Jan 17, 2022

Contributor

That's not what I meant, you do not need to call DataContainer::generateRowLabel yourself. In Contao <=4.12 you leave everything as it is. In Contao >=4.13 you only use the label_callback.

This comment has been minimized.

Copy link
@fritzmg

fritzmg Jan 17, 2022

Contributor

Also may be we should add the DataContainer to the callback? Seems like an oversight that that's one of the only DataContainer callbacks where we do not pass the DataContainer.

}

$archive = NewsArchiveModel::findByPk($row['pid']);

if (
Expand Down

0 comments on commit 9314351

Please sign in to comment.