Hi everyone,
I am pretty new to directus and i am experimenting to get all my use cases done and to it’s competitors find directus a neat piece of software, wether i think translations and blocks-builder (m2m) at it, while having a bit of a learning curve most things are mostly straightforward.
So my current task is that in my frontend application (planning to use SvelteKit but i think it’s pretty much the same in most alternatives), I want to have persistent Links that an editor/user/me to use in all sorts of scenarios, such as menu, footer, content building, having standard data structures like blog/pages.
Having a basic scenario like a slug change, the links should always find the correct. Flexible with different content types, and if possible, best case to feature a selection type.
What’s the most straightforward way of getting that done? In many tutorials I can see people working with a link’s relation, having e.g. pages + blog relation, external field which sets the whole thing up.
Any advice?
Best Regards,
Carsten
Hi Carsten, welcome to the community and thanks for your first post!
Awesome to see you digging into Directus.
For what you’re trying to do, one option could be setting up a dedicated links collection and then referencing it wherever you need, like in your menus, footers, or content. That might help keep everything consistent since all your links live in one place. Each link could either have a relation to a page, a blog post, or just store a plain URL, and then on the frontend you’d decide how to handle it.
I’ve seen setups where the links collection has a type field (page, blog, external), along with a relation to a page, a relation to a blog, and a plain URL field. Depending on the type selected, you’d use the corresponding field. When you fetch the data, you can include the related page or blog in your query so you always have the right target instead of hardcoding links.
Hi Connor,
that’s what i have also read so far - with having a global table for menu and footer links i think this is very straight forward.
What i really wonder, if the wysivyg / rich text editors are being used, if and how it’s possible to reference the same kind of relations for non-technical editors.
I’d love to see the ability to search different collections when adding links within our base WYSIWYG editor but obviously it’s tricky trying to keep those links up to date if a slug changes for a post or a page or something.
Do you have a preference for how you store the data/output for the rich text editor?
If you haven’t already take a look at the Flexible Editor extension by Florian Wachmann. It supports relational content through the use of the M2A relationships in Directus and outputs JSON.