Extract Url & Title from link field in Drupal 8?

后端 未结 11 668
一生所求
一生所求 2021-01-31 05:29

I\'m trying to retrieve the URL and the Title values of a Link field in Drupal 8.

In my custom controller, I retrieve the nodes with:<

11条回答
  •  一个人的身影
    2021-01-31 05:32

    Updated for Drupal 8

    To get the url all you need to do is:

    {{ content.field_link_name[0]['#url'] }}
    

    To get the link text:

    {{ content.field_link_name[0]['#title'] }}
    

提交回复
热议问题