Extract Url & Title from link field in Drupal 8?

后端 未结 11 646
一生所求
一生所求 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:33

    I am doing this link separation for ECK fields and this solution really helped me. I have updated the code for ECK fields for apply inline style in twig file like this:

    {{ entity.field_link[0]['#title'] }}

    To get url:
    {{ entity.field_link[0]['#url'] }}

    To get link title:
    {{ entity.field_link[0]['#title'] }}

提交回复
热议问题