Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Added newsListCountItems & newsListFetchItems hooks #430

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/extensions/hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ custom functionality to the core.
- [loadFormField](loadFormField.md)
- [loadLanguageFile](loadLanguageFile.md)
- [modifyFrontendPage](modifyFrontendPage.md)
- newsListCountItems
- newsListFetchItems
- [newsListCountItems](newsListCountItems.md)
- [newsListFetchItems](newsListFetchItems.md)
- [outputBackendTemplate](outputBackendTemplate.md)
- [outputFrontendTemplate](outputFrontendTemplate.md)
- [parseArticles](parseArticles.md)
Expand Down
52 changes: 52 additions & 0 deletions api/extensions/hooks/newsListCountItems.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# newsListCountItems

The `newsListCountItems` hook is triggered when the number of news items is
needed (before fetching a news list).

> #### primary:: Available
> from Contao 3.5.0.


## Parameters

1. *array* `$newsArchives`

An array containing news archives IDs.

2. *boolean* `$blnFeatured`

A boolean that indicates if the news list must display featured news.
Possible values are:
- `null` (display all news)
- `true` (display only featured news)
- `false` (display all news that are not featured)


## Example

```php
<?php

// config.php
$GLOBALS['TL_HOOKS']['newsListCountItems'][] = array('MyClass', 'myNewsListCountItems');

// MyClass.php
public function myNewsListCountItems($newsArchives, $blnFeatured)
{
// Do something
}
```


## More information


### References

- [system/modules/core/modules/ModuleNewsList.php](https://github.com/contao/core/blob/3.5.17/system/modules/news/modules/ModuleNewsList.php#L170)


### See also

- [newsListFetchItems](newsListFetchItems.md) - triggered when news list items
are fetched from database.
64 changes: 64 additions & 0 deletions api/extensions/hooks/newsListFetchItems.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# newsListFetchItems

The `newsListFetchItems` hook is triggered when news list items are fetched
from database.

> #### primary:: Available
> from Contao 3.5.0.


## Parameters

1. *array* `$newsArchives`

An array containing news archives IDs.

2. *boolean* `$blnFeatured`

A boolean that indicates if the news list must display featured news.
Possible values are:
- `null` (display all news)
- `true` (display only featured news)
- `false` (display all news that are not featured)

3. *int* `$limit`

Number of items that should be displayed.

4. *int* `$offset`

Offset of items to skip.

5. *ModuleNewsList* `$newsListModule`

The news list module that was used to fetch items.


## Example

```php
<?php

// config.php
$GLOBALS['TL_HOOKS']['newsListFetchItems'][] = array('MyClass', 'myNewsListFetchItems');

// MyClass.php
public function myNewsListFetchItems($newsArchives, $blnFeatured, $limit, $offset, \ModuleNewsList $newsListModule)
{
// Do something
}
```


## More information


### References

- [system/modules/core/modules/ModuleNewsList.php](https://github.com/contao/core/blob/3.5.17/system/modules/news/modules/ModuleNewsList.php#L203)


### See also

- [newsListCountItems](newsListCountItems.md) - triggered when the number of
news items is needed (before fetching a news list).