How to modify Drupal 8 Views "Rewrite..." field values later in code? In a Drupal 8.3 View, I am displaying fields. One of these fields is configured to "rewrite results" so as to "output this field as a custom link" with a custom link path.

I would like to modify these links in code (based on some later logic). However, I cannot find a place to actually modify this value in code. If someone knows how to accomplish this, please let me know. (This was much easier in D7.)

Here's what I've tried thus far.


theme_preprocess_views_view(): I found ...['#view'] -&gt; field['name'] -&gt; options['alter']['path'] in Drupal 8's endless arrays, but changing this value did not affect the output. I could not find my custom link anywhere else in this endless array.
hook_views_post_render(): This supposedly allows one to alter the output string, but doesn't actually give the output as a string (broken documentation).
I can see the output string in a twig template, but cannot easily substitute my link given that PHP doesn't run in twig. This would be a less desirable option in any case.
After more time and effort poking around, I found one possible solution, but perhaps not the best or most efficient.

What didn't work:

My original approach of changing the field path links in theme_preprocess_views_view() didn't work because this function is too late in the page build. ("Preprocess" is apparently contextual to the target function. In this case it comes before the final View, not the View's fields.)

I also tried using template_preprocess_views_view(), which was called before other View preprocess functions. While I was able to change the View rewrite values (e.g., $view -&gt; field['name'] -&gt; options['alter']['path'] = 'my new path'), this changed the links for all the fields, not allowing each field to be individually customized.

I was able to change the Views rewrite path value inside hook_preprocess_views_view_field(&amp;$variables), but this affected the following field in the results array, not the current field.

My Solution:

I ended up using hook_preprocess_views_view_field(&amp;$variables), and rendering my own custom links and saving them to $variables['output'].

$variables['view'] and $variables['row'] were available for finding data for the logic, as well as additional objects depending on what the View is displaying.

I also used template_preprocess_views_view() to re-organize all the Views rows before they were rendered in the twig template, but as mentioned before, I couldn't change the content of the rows inside this function because they were already rendered before this function was called.

I hope this saves time for someone. Feel free to post more eloquent solutions.