Extract Url & Title from link field in Drupal 8? - Printable Version +- 0Day Forums (https://0day.red) +-- Forum: Coding (https://0day.red/Forum-Coding) +--- Forum: CMS (https://0day.red/Forum-CMS) +---- Forum: Drupal (https://0day.red/Forum-Drupal) +---- Thread: Extract Url & Title from link field in Drupal 8? (/Thread-Extract-Url-amp-Title-from-link-field-in-Drupal-8) |
Extract Url & Title from link field in Drupal 8? - scaresome15544 - 07-24-2023 I'm trying to retrieve the *URL* and the *Title* values of a [Link field]( [To see links please register here] ) in **Drupal 8**.In my custom controller, I retrieve the nodes with: $storage = \Drupal::entityManager()->getStorage('node'); $nids = $storage->getQuery() ->condition('type', 'partners') ->condition('status', 1) ->execute(); $partners = $storage->loadMultiple($nids); When I loop throught all my nodes, to preprocess vars I'll give to my view, I would like to retrieve the *URL* and the *Title*. foreach ($partners as $key => $partner) { $variables['partners'][] = array( 'image' => $partner->field_logo->entity->url(), 'url' => $partner->field_link->value, // Can't retrieve values of link field ); } Unfortunately, I don't found how to retrieve the *URL* and the *Title* of **field_link**. Thanks for your help. |