Score:0

Set URL alias for dynamically created menu links via MenuLinkContent::create

in flag

I am creating a menu link via the MenuLinkContent::create method as follows:

MenuLinkContent::create([
  'title' => $createdNodeTitle,
  'link' => ['uri' => "entity:node/$createdNodeId"],
  'menu_name' => 'main',
  'parent' => array_key_first($menu_link),
])->save();

Which works fine. I'm looking for a parameter to pass to set a custom URL alias (as possible via UI)

Any way how this is possible?

Jaypan avatar
de flag
Aliases and menu links are entirely unrelated, so you'll need to give more information about what it is you're doing, and how you've been trying to do it, before we can nudge you in the right direction.
leymannx avatar
ne flag
I think Pathauto had a token for that. Something like menu joint path or so.
Kevin avatar
in flag
Yes, Pathauto has tokens to do join by menu path.
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.