I'm not entirely sure of the correct way to describe this,

but I have a View page setup for events.

One field is "Ticket Link" and Another is "Event Image"

The listing page is being displayed via a Structure / View setup.

I want the Image when clicked, to link to the URL that is sourced from the "Ticket Link" field (external links)

How would I do that?

Comments

TimeBandit’s picture

Couple ways:

1) add a field to the view of type "custom". in that custom field you basically rewrite your output using tokens (which reference your fields). So for example your custom field might be something like:

<a href="{{ field_ticket_link}}">{{ field_event_image }}</a>

You need to be sure your link field is set to plain URL, and not an actual full link. You should also then set your link field and your image field to "exclude from display" because you're calling them again in your new custom field.

2) you could use a views-view-fields--[view name].html.twig to theme the order of your fields any way you want. You'd basically replicate what I said above, just inside the twig instead of adding a new custom field.

barnamah’s picture

How can I add view of type "custom"? I don't see such option when I click on "Add" under field. 

devashish jangid’s picture

Hello 
Here  You have to add a field  with type custom.
>You can add this field  by  editing your view and  going to Fields heading >> Add ( button on its right side of fileds  heading)in your view.
> This will open a box, from here select custom text and click on apply button at the bottom. This will add a custom text field to your view.