Skip to content

Commit

Permalink
fix news palettes and user picker
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Jun 10, 2022
1 parent 25c0a91 commit 6095f70
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
10 changes: 6 additions & 4 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
])
;

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
Expand All @@ -29,9 +29,11 @@
'escape_implicit_backslashes' => true,
'fully_qualified_strict_types' => true,
'general_phpdoc_annotation_remove' => [
'author',
'expectedException',
'expectedExceptionMessage',
'annotations' => [
'author',
'expectedException',
'expectedExceptionMessage',
],
],
'header_comment' => ['header' => $header],
'heredoc_to_nowdoc' => true,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"require":{
"php": ">=7.1",
"contao/core-bundle": "^4.4"
"contao/core-bundle": "^4.9"
},
"require-dev": {
"contao/manager-plugin": "^2.0"
Expand Down
26 changes: 18 additions & 8 deletions src/Resources/contao/dca/tl_news.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@
* (c) fritzmg
*/

$GLOBALS['TL_DCA']['tl_news']['palettes']['default'] .= ';{related_news_legend:hide},relatedNews';
use Contao\CoreBundle\DataContainer\PaletteManipulator;

$GLOBALS['TL_DCA']['tl_news']['fields']['relatedNews'] = [
'label' => &$GLOBALS['TL_LANG']['tl_news']['relatedNews'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => ['contao_newsrelated.listener.news', 'relatedNewsOptionsCallback'],
'foreignKey' => 'tl_news.headline',
'eval' => ['multiple' => true, 'chosen' => true, 'tl_style' => 'height:auto', 'tl_class' => 'clr'],
'relation' => ['type' => 'belongsToMany', 'load' => 'lazy'],
'sql' => 'blob NULL',
'inputType' => 'picker',
'eval' => ['multiple' => true, 'fieldType' => 'checkbox', 'tl_class' => 'clr'],
'relation' => ['type' => 'belongsToMany', 'load' => 'lazy', 'table' => 'tl_news'],
'sql' => ['type' => 'blob', 'length' => 65535, 'notnull' => false],
];

$pm = PaletteManipulator::create()
->addLegend('related_news_legend', null, PaletteManipulator::POSITION_AFTER, true)
->addField('relatedNews', 'related_news_legend', PaletteManipulator::POSITION_APPEND)
;

foreach ($GLOBALS['TL_DCA']['tl_news']['palettes'] as $name => $palette) {
if (!\is_string($palette)) {
continue;
}

$pm->applyToPalette($name, 'tl_news');
}

0 comments on commit 6095f70

Please sign in to comment.