Hey!
Let’s suppose that I have a blog model (and about 200 entries from it) with 3 type of inputs: title, description, url.
Is it somehow possible that I bind the url field to the value of the title using custom js code?
If the title is: “My first blog article?”
I want that my url automatically will be: “my-first-blog-article”, because it can be very tedious to add this url manually each time
Something like
url=state.title.toLowerCase().replace(" “,”-“).replace(”?“,”")
Or something like that.
Please let me know if it is possible, because it would be a very convenient way of solving this auto binding issue.
logan
April 21, 2022, 12:24pm
2
Hey @radikris !
While this video is a little older, you’ll find your answer here: Dynamic urls with advanced fetching in Builder.io - YouTube
You can edit the URL of the page using state.location.path
.
Thank you, and please let us know if you have any further questions!
thanks @logan ,but I think you misunderstood my question:
I have this model entry:
I want to generate an url for this automatically from the title, with this rule:
url=state.title.toLowerCase().replace(" “,”-").replace("?","")
So this way, the url would be first-personal-question, without I have to type that manually. Is it possible?
logan
April 21, 2022, 12:45pm
4
Thank you for clarifying!
That isn’t possible right now, but you can submit a feature request for an auto-generated Slug field at our Ideas page. This is a great idea!
1 Like
Thank you very much for your response @logan !
Can you please help me:
I will leave the main issue here:
Code:
#!/usr/bin/node
import fetch from "node-fetch";
const privateKey = "PRIVATEKEY";
const runScript = async () => {
const allContent = await fetch(
"https://cdn.builder.io/api/v2/content/localizemodelexample?apiKey=32f148657e2646be8562eb4e6ebfa190&limit=1&fields=data.title,data.description"
).then((res) => res.json());
allContent.results.map(async (entry) => {
//grab the current image
console.log(entry);
const originalDefaultTitle =…
@TimG is out of stock, and I need this urgent. Thank you very much!
logan
April 21, 2022, 2:56pm
6
Hey @radikris ,
I’ve reached out to my Customer Engineer team to take a look at that forum post. Thank you!