Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

How do get document data within Collection custom component?

default discord avatar
plaguefps4 months ago
2

I'm trying to create a "view page" button using a UI field within the relevant collection and I'm not sure how I'm supposed to get any of the document data I need to generate the URL



Yeah I saw the documention on this hooks existence but the only valuable information I could find returned from this hook was the doc's slug, but, I need more than that.



Specifically I need the doc's slug and the id of the category it is related to so I can fetch that category and generate the URL since the URL structure is

https://mywebsite/category/slug

No I got a bunch of other values, but, none of them looked like it would give me what I needed, kinda wish the docuementation explained what some of the values are



Oh on second glance it may be the

initialData

, if not I can post the returned value, let me test this real quick though



Yup, the

initialData

gets me the docs fields and values, this is what I needed I apologize for not seeing this value during my first pass and making a post about it lol

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.