Score:-3

How can read/write information from HTML?

gd flag
jwa

I have a content type that includes 2 URL links.

  • The first like: previousURL = /blog/day9
  • The second like: nextURL = /blog/day11.

So I can easily switch from the current page to a previous or a next page.

The problem is when I change the language from the default language to e.g. french the links should be changed to /fr/blog/day9 and /fr/blog/day11.

I have no idea what functions to use for reading and writing to these fields with the asset javascript injector in Drupal 10.

id flag
Are those fields entity references or text fields where you type a link?
cn flag
Why do you need javascript here ? Is your Drupal in a monolith architecture ? (Using Twig ?)
jwa avatar
gd flag
jwa
The previousURL and nextURL are link fields and are filled in simultaneously with other fields such as title, body, images, etc. when creating a new blog page.
jwa avatar
gd flag
jwa
Why use javascript? I thought this was the easiest way. I also had to find out the current language. I found out that I could do this with "let currLang = drupalSettings.path.currentLanguage;". So I assumed there should also be similar commands to read and change the link fields I'm interested in.
id flag
I have a feeling that if you use entity reference fields, Drupal will write the language links as you would expect. Having to write JavaScript doesn't make sense.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.