Skip to content

Commit

Permalink
added disableEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Oct 10, 2017
1 parent f56f3de commit 21f93f3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/Models/NewsRelatedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
return null;
}

// define the return value for no item
$retNoItem = $objModule->disableEmpty ? false : null;

// get the table and prepare columns, values and options
$t = \NewsModel::getTable();
$arrColumns = array("$t.pid IN(" . implode(',', array_map('intval', $newsArchives)) . ")");
Expand All @@ -69,7 +72,7 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
// check if there is an active tem
if (!$item)
{
return null;
return $retNoItem;
}

// get the news
Expand All @@ -78,7 +81,7 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
// check if news was found
if (!$objNews)
{
return null;
return $retNoItem;
}

// Get the related news
Expand All @@ -87,7 +90,7 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
// Check if any related news are defined
if (!$arrRelated)
{
return null;
return $retNoItem;
}

// add related news
Expand Down Expand Up @@ -151,7 +154,7 @@ public function newsListFetchItems($newsArchives, $blnFeatured, $limit, $offset,
unset($GLOBALS['NEWS_FILTER_CATEGORIES'], $GLOBALS['NEWS_FILTER_DEFAULT'], $GLOBALS['NEWS_FILTER_PRESERVE']);
}

// Return result
return self::findBy($arrColumns, $arrValues, $arrOptions);
// get the result
return self::findBy($arrColumns, $arrValues, $arrOptions) ?: $retNoItem;
}
}
11 changes: 10 additions & 1 deletion src/Resources/contao/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/


$GLOBALS['TL_DCA']['tl_module']['palettes']['newslist'] = str_replace(',skipFirst', ',skipFirst,relatedOnly', $GLOBALS['TL_DCA']['tl_module']['palettes']['newslist']);
$GLOBALS['TL_DCA']['tl_module']['palettes']['newslist'] = str_replace(',skipFirst', ',skipFirst,relatedOnly,disableEmpty', $GLOBALS['TL_DCA']['tl_module']['palettes']['newslist']);

$GLOBALS['TL_DCA']['tl_module']['fields']['relatedOnly'] = array
(
Expand All @@ -20,3 +20,12 @@
'eval' => array('tl_class'=>'clr w50'),
'sql' => "char(1) NOT NULL default ''"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['disableEmpty'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['disableEmpty'],
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "char(1) NOT NULL default ''"
);
1 change: 1 addition & 0 deletions src/Resources/contao/languages/de/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@


$GLOBALS['TL_LANG']['tl_module']['relatedOnly'] = array('Nur verwandte Einträge anzeigen','Beschränkt die Ausgabe auf verwandte Artikel.');
$GLOBALS['TL_LANG']['tl_module']['disableEmpty'] = array('Keine leere Ausgabe','Zeigt alle Nachrichtenartikel an, wenn keine verwandten Artikel gefunden wurden.');
1 change: 1 addition & 0 deletions src/Resources/contao/languages/en/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@


$GLOBALS['TL_LANG']['tl_module']['relatedOnly'] = array('Show only related entries','Limits the output to related entries.');
$GLOBALS['TL_LANG']['tl_module']['disableEmpty'] = array('Disable empty output','Shows all news entries, if no related entries have been found.');

0 comments on commit 21f93f3

Please sign in to comment.