---
title: "Demands"
manual: "News system"
version: "main"
permalink: "https://docs.typo3.org/permalink/georgringer/news:demands@main"
source: "Tutorials/ExtendNews/Demands/Index.rst"
rendered: "2026-09-23T19:24:09+00:00"
---

# Demands {#demands}

A demand is a configuration object used by the repository to decide which
news records should be fetched.

The default demand class implementation for the frontend output of news
is `\GeorgRinger\News\Domain\Model\Dto\NewsDemand`. It has a couple of
useful properties that can be used to filter news records, for example
`$categories`, `$searchFields`, `$author` and many more.

There is also the property `$customSettings` an array of custom settings
by extensions. You should use your extension name as key in this array.

Demand objects can be changed in a couple of ways, see below:

## URL Parameter {#url-parameter}

The URL parameter `overwriteDemand` can be used to override properties
of the demand.

You can set this parameter in a Fluid link (see
[Set overwriteDemand in Frontend](https://docs.typo3.org/permalink/georgringer/news:overwritedemand-in-frontend@main)) or via
TypoScript in a typolink (See
[TypoScript reference: typolink](https://docs.typo3.org/m/typo3/reference-typoscript/13.4/en-us/Functions/Typolink.html#typolink)).

It would even be possible to configure a [LinkHandler](https://docs.typo3.org/permalink/georgringer/news:linkhandler@main)
for this parameter.

> [!IMPORTANT]
> The checkbox **Disable override demand** in the list plugin
> (Tab Additional) must **not** be set to allow overriding the properties.
>
> Additionally the TypoScript setting
> [settings.disableOverrideDemand](https://docs.typo3.org/permalink/georgringer/news:tsdisableoverridedemand@main) must be set to
> `0`.

## Via TypoScript {#via-typoscript}

TypoScript can be used to define a class containing a
[custom implementation](https://docs.typo3.org/permalink/georgringer/news:demand-custom@main)
of the demand object. This can be achieved by the TypoScript setting
[settings.demandClass](https://docs.typo3.org/permalink/georgringer/news:tsdemandclass@main).

## Custom controllers {#custom-controllers}

The demand object can be used in a custom controller used in an extension
extending EXT:news. Read more about using a demand object in a custom
controller:
[Extension based on EXT:news: FilterController.php](https://docs.typo3.org/permalink/georgringer/news:extension-custom-controller@main).

## Building a demand outside of a controller {#demand-factory}

The service `\GeorgRinger\News\Service\NewsDemandFactory` turns a settings
array - typically the TypoScript settings of a news plugin - into a demand
object. Use it whenever news records have to be fetched outside of the
`NewsController`, for example in a ViewHelper, a DataProcessor, a
middleware or an API endpoint.

The service applies the same rules as the plugin does: it respects
[settings.demandClass](https://docs.typo3.org/permalink/georgringer/news:tsdemandclass@main), resolves
`settings.startingpoint` and `settings.recursive` into the storage
page list and dispatches the
`\GeorgRinger\News\Event\CreateDemandObjectFromSettingsEvent`. Listeners
registered for that event therefore also apply to demands built this way.

```php
<?php

namespace Vendor\MyNews\Api;

use GeorgRinger\News\Domain\Repository\NewsRepository;
use GeorgRinger\News\Service\NewsDemandFactory;

class LatestNewsProvider
{
   public function __construct(
      private readonly NewsDemandFactory $newsDemandFactory,
      private readonly NewsRepository $newsRepository
   ) {}

   public function findLatest(int $storagePid): array
   {
      $demand = $this->newsDemandFactory->create([
         'startingpoint' => (string)$storagePid,
         'orderBy' => 'datetime',
         'orderDirection' => 'desc',
         'limit' => 5,
      ]);

      return $this->newsRepository->findDemanded($demand)->toArray();
   }
}
```

The second, optional argument of `create()` defines the demand class to
use when the settings contain no `demandClass` key:

```php
$demand = $this->newsDemandFactory->create($settings, MyNewsDemand::class);
```

> [!NOTE]
> The protected method `NewsController::createDemandObjectFromSettings()`
> is deprecated since version 14.1 and only delegates to this service. Custom
> controllers extending `NewsController` should use the factory or the
> `CreateDemandObjectFromSettingsEvent` instead of overriding it.

## Events {#events}

Multiple events can change or use demand objects. For example the events of
the main actions in the `NewsController`, for example
`NewsListActionEvent` and `NewsDetailActionEvent`. For more
information refer to the chapter [Events](https://docs.typo3.org/permalink/georgringer/news:events@main).

## Custom demand class {#demand-custom}

All custom frontend news demand classes must extend
`\GeorgRinger\News\Domain\Model\Dto\NewsDemand`. The demand object is
a simple configuration object. It should contain no business logic. For each
property there must be a setter and a getter.

Example:

```php
<?php

namespace Vendor\MyNews\Domain\Model\Dto;

use \GeorgRinger\News\Domain\Model\Dto\NewsDemand;

class MyNewsDemand extends NewsDemand {

   /**
   * @var string
   */
   protected $myCustomField = '';

   /**
   * Set myCustomField
   *
   * @param string $myCustomField
   * @return NewsDemand
   */
   public function setMyCustomField(string $myCustomField): NewsDemand
   {
      $this->myCustomField = $myCustomField;
      return $this;
   }

   /**
   * Get myCustomField
   *
   * @return string
   */
   public function getMyCustomField(): string
   {
      return $this->myCustomField;
   }
}
```
