I have a search results View which list the (Commerce) products. I show the title and the image fields. I those fields to wrap in a custom <a> link tag. When I am adding fields, I miss the 'Link to product' field, so I am able to rewrite the fields and use the path {{ path }} token and theme it to my needs.

Do I miss or do I have to activate something?


The Path field has been deprecated, use Link to content instead. More info in this answer: How to get Node Url in RSS view?

When you have to construct a different output out of field values it's good to use the Custom text Field.

Exclude from display your Title, Image, and Link to content fields, reorder the fields so the Custom text field comes last.

Enter your anchor HTML into the Custom text area and use the Replacement patterns you see in the list below the area to construct the full HTML code. One of them will be the URL token. Something like:

<a href="{{ view_node }}">{{ title }} {{ field_image }}</a>

Make sure your Title field settings aren't using links, and you may have to adjust the image field code further.

  • The Link to content isn't available in the Search API search result view...? Maybe it's because I am try linking to Commerce products? – meez Jul 9 '19 at 21:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.