How to use place holders in Rich text field?

I have one generic page (cookie cutter) in Prismic that I want to use for serving multiple URLs. Within this Prismic page I want to have some way to have placehoders that can be replaced beforing serving the final content. For example I would like to change the content heading (Rich Text Field) to make it specific to URL being requested. That way although its a generic page I still can make it bit unque for each URL.

What would be the approaches to achieve this requirement?

Hello @gru.singh, welcome to the Community!

It depends on which placeholder you are referring to. For example, all Fields in Prismic have a field that allows you to add placeholders that appear within documents. These work as an informative piece to make the use of each Field clearer. These are configured within the configuration of each Field. Here we can see the example of the Rich Text:

image

If you're referring to the placeholders that may appear within your application, like the ones used in <form> elements, then what you need is to add a text Field to add to the placeholder. This can be a Key Text or a Select Field.

What do you want to do with the URLs you mention, where are you managing these?

Sorry I picked wrong words to describe my requirements. Here is another attempt:

I have a cookie cutter page (generic page) say for book detail. I want to use the same page for all the books in my catalogue. I can load book details based on requested URL from an api and would like to replace come text in the cookie cutter page to make it unique.

URL: www.mysite.com/books/alice-in-wonderland
URL: www.mysite.com/books/moby-dick

My cookie cutter page is written as generic page for any book. But I want to partially replace content of a header (Key Text Field) and partial content in Rich Text Field.

The data comes from an walled api and there is no easy way to expose it to Primic to enable Integration Fields feature.

Here is a screenshot:

Is this site, the cookie cutter page, already integrated with Prismic or not yet? Could you show me an example of the page you're trying to edit?

I have attached screenshot of three prismic pages.

  • Alice in wonderland
  • Moby Dick
  • cookie-cutter

As you can see most of content on Alice in Wonderland and Moby Dick page is going to be same. Only few things like Book Name is going to change. I don't want to create 1000's of book pages with similar content. Instead I am thinking of a single page (cookie-cuttter) in Prismic where I can leave some markers/placeholders like __book-name__

When user requests a book URL I will fetch the cookie-cutter prismic page and also fetch book details from an api. Then replace markers/placehoders in cookie-cutter Prismic page with real values pulled from an api.



Thanks for the clarification. When you mentioned a cookie cutter, I thought it was the template we use to build your app. :grinning_face_with_smiling_eyes:.

This is completely doable. You'll need to handle the logic from the front-end of your application, but what you can do within Prismic is to use Custom labels. They help you wrap the text in a <span> tag. Then, in your code, you can exchange what appears inside these labels for the values you want.

This thread has been closed due to inactivity. Flag to reopen.