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?
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:
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.
I have attached screenshot of three prismic pages.
Alice in wonderland
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. .
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.
closed , flag & select 'Something Else' to reopen.