I'm building a mobile app that has a list view which displays links to articles. The app's content is powered by Directus.
The list view has
title
description (200 characters, no HTML)
image
An article has
title
content (html)
image
To save the size of API requests, I'm storing the list view data in a collection called articles_list
and articles in a collection called articles
.
To keep Directus intuitive for the author, I need Directus to automatically create/update/delete an item in the articles_list
collection for when an item is created/updated/deleted in the articles
collection.
Both collections store basically the same data except that articles_list
has description
instead of content
. The description
field has the first 200 characters of content
after the HTML tags have been removed.
I've had a look at the hooks documentation but I'm not sure how to create a new item in a different collection (articles_list
). What's the best way of using an external library such as ezyang/htmlpurifier? How do I go about debugging my hook?
Any help would be greatly appreciated. I'm still learning to understand how Directus works.