Skip to content

Commit 9c9551e

Browse files
committed
Document generic solution for 'mark as read' in list views
Closes #537
1 parent 2880f35 commit 9c9551e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/php/api/list_views.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,32 @@ The following template code must be included in the template for rendering of th
392392
393393
{unsafe:$view->renderInteractionContextMenuButton($article)}
394394
```
395+
396+
## Mark as Read
397+
398+
If your objects can be marked as read, list views provide an abstract implementation for this.
399+
The `setMarkAsReadEndpoints(string $endpoint): void` method allows you to configure the corresponding RPC endpoint.
400+
401+
```php
402+
final class ExampleGridView extends AbstractListView
403+
{
404+
public function __construct()
405+
{
406+
...
407+
408+
$this->setMarkAsReadEndpoints('core/example/%s/mark-as-read');
409+
}
410+
}
411+
```
412+
413+
In the template code, the corresponding button can be created for each object using the `renderMarkAsReadButton(DatabaseObject $object): string` method.
414+
415+
```smarty
416+
{foreach from=$view->getItems() item='item'}
417+
...
418+
{if $item->isNew()}
419+
{unsafe:$view->renderMarkAsReadButton($item)}
420+
{/if}
421+
...
422+
{/foreach}
423+
```

0 commit comments

Comments
 (0)