I want to use hook_views_pre_render() to read in a view and change a field output to a clickable link.
Here is code:
function sbn_views_pre_render(ViewExecutable $view) {
// https://drupal.stackexchange.com/questions/272495/how-to-get-views-field-names-values-for-hook-views-pre-render
if ($view->id() == 'find_paragraphs') {
foreach ($view->result as $key => $value) {
$parent_id_value = $value->_entity->parent_id->getValue()[0]['value'];
$parent_type_value = $value->_entity->parent_type->getValue()[0]['value'];
$private_files = $value->_entity->field_private_files->getValue()[0]['value'];
if ($parent_type_value == 'node') {
$link = '<a href="/node/'.$parent_id_value.'">'.$parent_id_value.'</a>';
// $value->_entity->set('parent_id', $link);
}
if ($parent_type_value == 'paragraph') {
}
}
}
}
Formatting the $link value using standard html coding does not work. Any ideas on how to format the link from within this hook so that the rendered field is a clickable link?
$view->result[$key]
instead of$value
like$view->result[$key]->_entity->set('parent_id', $link);
and see!