views – Get the link node

In the mymodule_preprocess_views_view_row_rss (& $ variables) hook, we are able to get the link using $ variables['row']-> link. However, we can not access the node for who link is for.

How can we use the value returned by $ variables['row']-> link to get the node?


  1. Using the link value, get the node so that we can fetch additional fields such as field_image in the hook
  2. Add the field_image as variable to $ variables chart so that it can be used in the views-view-row-rss.html.twig file.

We tried without success.

function mymodule_preprocess_views_view_row_rss (& $ variables) {
$ link_value = $ variables['row']-> link;
$ path =  Drupal :: service (`path.alias_manager`) -> getPathByAlias ​​($ link_value);
$ node =  Drupal  node  Entity  Node :: load ($ path);
ksm ($ node); // return null.

Additional display settings that we tried unsuccessfully:

Under the fields


In mymodule_preprocess_views_view_row_rss (& $ variables) crochet, we tried to print all the variables using ksm ($ variables) To see if field_image was returned, but it was not.