Skip to content

How to save Urlrelations in Craft 5? #16689

Answered by roland-d
roland-d asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @AugustMiller,

Thank you for your reply. That put me in the right direction of ending up to make it work 🥳

There were 3 things I had to change:

  1. The sortOrder is required now otherwise it will not save the changes
  2. the type value has changed during the migration, not something I noticed. The new name is now urlRelations2 instead of urlRelations. One of those things that can take hours to spot 😅
  3. The new placeholder should be changed to new:. Notice the colon at the end.

My final code is:

foreach ($urls as $url) {
    $urlRelations['entries']['new:' . $key] = [
        'type' => 'urlRelations2',
        'enabled' => true,
        'fields' => [
            'href' => [
                    't…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by roland-d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants