-1

I am struggling with changing the URL of my field in a view. I am using the following code.

function mymodule_views_pre_render(&$view) {
 $view->field['title']->options['alter']['text'] = 'My custom text';
 $view->field['title']->options['alter']['alter_text'] = TRUE;
 $view->field['title']->options['alter']['make_link'] = TRUE;
 $view->field['title']->options['alter']['path'] = "http://url.com";
}

The title changes, but the link doesn't.

Any idea?

3
  • Did you try custom field template for this?
    – Codium
    Jul 5 '17 at 12:26
  • Custom field template? Could you please provide more detail on this?
    – user24189
    Jul 5 '17 at 13:43
0

It seems to me that you need to use matching quotation marks in the second line. Your current code has this: 'My custom text"

It should have this: 'My custom text'

That is, you have a single quotation mark to open the string, but a double quotation mark to close it. That's causing the rest of your block to be quoted. Change the double quotation mark to a single quotation mark.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy