Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Added an option to skip featured news in the news list (#1378)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed May 24, 2010
1 parent 2d2c3b8 commit 6759a20
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions contao-2.9/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Version 2.9.RC1 (2010--)
- Added: moved the global UTF8_LOOKUP_TABLE to a separate file (#1965)
- Added: added SSL/TLS support to the e-mail class (#1773)
- Added: added an additional confirmation to the "send newsletter" button (#1929)
- Added: added an option to skip featured news in the news list (#1378)
- Fixed: recoverable error in the registration module (#1926)
- Fixed: the event list did not show a "read more" link when redirecting to an article (#1944)
- Fixed: the textarea widget did not ignore the maxlength attribute (#1960)
Expand Down
3 changes: 3 additions & 0 deletions contao-2.9/contao/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ public function run()
$this->Database->prepare("UPDATE " . $objUser->tbl . " %s WHERE id=?")
->set($set)
->execute($objUser->id);

// Update the news list modules
$this->Database->query("UPDATE tl_module SET news_featured='featured' WHERE news_featured=1");
}
}

Expand Down
4 changes: 2 additions & 2 deletions contao-2.9/system/modules/news/ModuleNewsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function compile()
}

// Get the total number of items
$objTotal = $this->Database->execute("SELECT COUNT(*) AS total FROM tl_news WHERE pid IN(" . implode(',', array_map('intval', $this->news_archives)) . ")" . ($this->news_featured ? " AND featured=1" : "") . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<$time) AND (stop='' OR stop>$time) AND published=1" : "") . " ORDER BY date DESC");
$objTotal = $this->Database->execute("SELECT COUNT(*) AS total FROM tl_news WHERE pid IN(" . implode(',', array_map('intval', $this->news_archives)) . ")" . (($this->news_featured == 'featured') ? " AND featured=1" : (($this->news_featured == 'unfeatured') ? " AND featured=''" : "")) . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<$time) AND (stop='' OR stop>$time) AND published=1" : "") . " ORDER BY date DESC");
$total = $objTotal->total - $skipFirst;

// Split the results
Expand Down Expand Up @@ -130,7 +130,7 @@ protected function compile()
$this->Template->pagination = $objPagination->generate("\n ");
}

$objArticles = $this->Database->prepare("SELECT *, author AS authorId, (SELECT title FROM tl_news_archive WHERE tl_news_archive.id=tl_news.pid) AS archive, (SELECT jumpTo FROM tl_news_archive WHERE tl_news_archive.id=tl_news.pid) AS parentJumpTo, (SELECT name FROM tl_user WHERE id=author) AS author FROM tl_news WHERE pid IN(" . implode(',', array_map('intval', $this->news_archives)) . ")" . ($this->news_featured ? " AND featured=1" : "") . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<$time) AND (stop='' OR stop>$time) AND published=1" : "") . " ORDER BY date DESC");
$objArticles = $this->Database->prepare("SELECT *, author AS authorId, (SELECT title FROM tl_news_archive WHERE tl_news_archive.id=tl_news.pid) AS archive, (SELECT jumpTo FROM tl_news_archive WHERE tl_news_archive.id=tl_news.pid) AS parentJumpTo, (SELECT name FROM tl_user WHERE id=author) AS author FROM tl_news WHERE pid IN(" . implode(',', array_map('intval', $this->news_archives)) . ")" . (($this->news_featured == 'featured') ? " AND featured=1" : (($this->news_featured == 'unfeatured') ? " AND featured=''" : "")) . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<$time) AND (stop='' OR stop>$time) AND published=1" : "") . " ORDER BY date DESC");

// Limit the result
if (isset($limit))
Expand Down
2 changes: 1 addition & 1 deletion contao-2.9/system/modules/news/config/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ CREATE TABLE `tl_news_archive` (

CREATE TABLE `tl_module` (
`news_archives` blob NULL,
`news_featured` char(1) NOT NULL default '',
`news_featured` varchar(16) NOT NULL default '',
`news_numberOfItems` smallint(5) unsigned NOT NULL default '0',
`news_jumpToCurrent` char(1) NOT NULL default '',
`news_metaFields` varchar(255) NOT NULL default '',
Expand Down
7 changes: 5 additions & 2 deletions contao-2.9/system/modules/news/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@
$GLOBALS['TL_DCA']['tl_module']['fields']['news_featured'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['news_featured'],
'default' => 'all_items',
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50 m12')
'inputType' => 'select',
'options' => array('all_items', 'featured', 'unfeatured'),
'reference' => &$GLOBALS['TL_LANG']['tl_module'],
'eval' => array('tl_class'=>'w50')
);

$GLOBALS['TL_DCA']['tl_module']['fields']['news_jumpToCurrent'] = array
Expand Down
11 changes: 7 additions & 4 deletions contao-2.9/system/modules/news/languages/de/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Fields
*/
$GLOBALS['TL_LANG']['tl_module']['news_archives'] = array('Nachrichtenarchive', 'Bitte wählen Sie ein oder mehrere Nachrichtenarchive.');
$GLOBALS['TL_LANG']['tl_module']['news_featured'] = array('Nur hervorgehobene Beiträge', 'Nur hervorgehobene Beiträge in der Nachrichtenliste anzeigen.');
$GLOBALS['TL_LANG']['tl_module']['news_featured'] = array('Hervorgehobene Beiträge', 'Hier legen Sie fest, wie hervorgehobene Beiträge gehandhabt werden.');
$GLOBALS['TL_LANG']['tl_module']['news_numberOfItems'] = array('Gesamtzahl der Beiträge', 'Hier können Sie die Gesamtzahl der Beiträge festlegen. Geben Sie 0 ein, um alle anzuzeigen.');
$GLOBALS['TL_LANG']['tl_module']['news_jumpToCurrent'] = array('Zum aktuellen Zeitraum springen', 'Automatisch zum aktuellen Zeitraum springen, wenn keiner ausgewählt ist.');
$GLOBALS['TL_LANG']['tl_module']['news_metaFields'] = array('Meta-Felder', 'Hier können Sie die Meta-Felder auswählen.');
Expand All @@ -46,8 +46,11 @@
/**
* Reference
*/
$GLOBALS['TL_LANG']['tl_module']['news_day'] = 'Tag';
$GLOBALS['TL_LANG']['tl_module']['news_month'] = 'Monat';
$GLOBALS['TL_LANG']['tl_module']['news_year'] = 'Jahr';
$GLOBALS['TL_LANG']['tl_module']['news_day'] = 'Tag';
$GLOBALS['TL_LANG']['tl_module']['news_month'] = 'Monat';
$GLOBALS['TL_LANG']['tl_module']['news_year'] = 'Jahr';
$GLOBALS['TL_LANG']['tl_module']['all_items'] = 'Alle Beiträge anzeigen';
$GLOBALS['TL_LANG']['tl_module']['featured'] = 'Nur hervorgehobene Beiträge anzeigen';
$GLOBALS['TL_LANG']['tl_module']['unfeatured'] = 'Hervorgehobene Beiträge überspringen';

?>
11 changes: 7 additions & 4 deletions contao-2.9/system/modules/news/languages/en/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Fields
*/
$GLOBALS['TL_LANG']['tl_module']['news_archives'] = array('News archives', 'Please select one or more news archives.');
$GLOBALS['TL_LANG']['tl_module']['news_featured'] = array('Featured items only', 'Show only featured news items in the list.');
$GLOBALS['TL_LANG']['tl_module']['news_featured'] = array('Featured items', 'Here you can choose how featured items are handled.');
$GLOBALS['TL_LANG']['tl_module']['news_numberOfItems'] = array('Total number of items', 'Here you can limit the total number of news items. Set to 0 to show all.');
$GLOBALS['TL_LANG']['tl_module']['news_jumpToCurrent'] = array('Jump to current period', 'Automatically jump to the current period if none is selected.');
$GLOBALS['TL_LANG']['tl_module']['news_metaFields'] = array('Meta fields', 'Here you can select the meta fields.');
Expand All @@ -46,8 +46,11 @@
/**
* Reference
*/
$GLOBALS['TL_LANG']['tl_module']['news_day'] = 'Day';
$GLOBALS['TL_LANG']['tl_module']['news_month'] = 'Month';
$GLOBALS['TL_LANG']['tl_module']['news_year'] = 'Year';
$GLOBALS['TL_LANG']['tl_module']['news_day'] = 'Day';
$GLOBALS['TL_LANG']['tl_module']['news_month'] = 'Month';
$GLOBALS['TL_LANG']['tl_module']['news_year'] = 'Year';
$GLOBALS['TL_LANG']['tl_module']['all_items'] = 'Show all news items';
$GLOBALS['TL_LANG']['tl_module']['featured'] = 'Show featured news items only';
$GLOBALS['TL_LANG']['tl_module']['unfeatured'] = 'Skip featured news items';

?>

0 comments on commit 6759a20

Please sign in to comment.