hello, in a richtext i'm give a internal link to any text. but richtext not give a href on selected text on frontend.
Hey @bhavikak, would love to help here. Could you show me how you are generating your html for your richtext content on the front-end?
You can find more information on how to get your richtext rendering on the front-end here:
https://payloadcms.com/docs/fields/rich-text#generating-htmlAlso, here is how we are setting up our RichText field on our website cms, as well as, how we then render our richtext on the front-end of our website:
-
https://github.com/payloadcms/website-cms/tree/main/src/fields/richText-
https://github.com/payloadcms/website/tree/main/src/components/RichTextIn the above example, we are rendering link options for internal links & custom urls. Let me know if this helps! If you have any other questions or want to send me what your configuration is looking like, I'd be happy to take a look!
thanks @patrikkozak for detailed reference. i'll try with this example.
hello @patrikkozak when i'm giving a internal link to the text it store only this "doc": {
"value": "64104734ff4d723aa221d90d",
"relationTo": "subpages"
},
how can i get slug
doc
should be returning
value
and
relationTo
. However,
value
should be returning an object of the documents data that you are linking to - including the slug.
e.g.
value
object should look something like this:
"value": {
"id": "64398f0d37313dd53aac55c0",
"title": "Example Page",
"fullTitle": "Example Page",
"hero": {},
"layout": [],
"slug": "example-page",
"meta": {},
"breadcrumbs": [],
"_status": "published",
"createdAt": "2023-04-14T17:36:13.480Z",
"updatedAt": "2023-04-14T17:36:13.712Z"
},
What does your richtext config look like? And what does your richtext component look like on the front-end?
this is probably an access control issue
your
subpage
is not populating. are you using
depth
? is this the REST API or GraphQL? if you are using depth properly, you should make sure that you have
read
access to your subpages collection
heyy @jmikrut i add maxdepth = 5 in payload.config.ts but it's not work
and also i have a read access of subpages collection.
access: {
read: anyone,
create: adminsAndUser,
update: adminsAndUser,
delete: admins,
}, this is my access control for subpages collection
@patrikkozak thi is my richtext config look like
and my frontend richtext component look like
@bhavikak it's not
maxDepth
that would do this - it would be just straight up
depth
maxDepth limits the total depth available for the field but you still need to pass
depth
, which defaults to 2
i take it you're seeing this behavior in the REST API?
i also added in rest api but it's not working
like this
http://localhost:8000/api/subpages/642e8045da4d9e94077bcedc?draft=true&&depth=10
@jmikrut can you tell me where i have to add depth config.
ok - your query is correct then, and you need to look at access control
if access control does not pass for the "populated" documents, then it will remain as the ID only
can you tell me how can i pass access control for the populated documents.
that depends on your
read
access control itself
just to be clear, above, you said that your subpages collection has this access control:
read: anyone,
what is in the
anyone
function?
heyy @jmikrut this is my anyone hook
ok then it should not be access control that is preventing this after all
we will likely need a minimally reproducible repo to help diagnose this further
you should start with a fresh project, with open access control, and see that it is working
and then add in your own code until it
stopsworking
and then we can help from there
this does indeed work (we use it all the time) so it's got to be something with your implementation
can you tell me my hook is correct or not.
you mean your access control?
your access control is correct
okay
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.