0

I have a custom content type which collects one image and one URL per node. I have the Slick module along with Views set up to cycle through these images on the home page. I haven't been able to make the carousel images link to the external URLs. In Views I have this:

screenshot of carousel in Views

In the Global: Custom text field, I have this:

<a href="{{ field_library_homepage }}">{{ field_library_photo }}</a>

It's not using that markup. What's most confusing is that the images are displaying in the carousel. I have the photo field hidden and Drupal isn't using the custom text so I don't know how those images are being accessed.

What step have I missed to make this work? Thanks!

4
  • {{ field_library_homepage.0.value }} or {{ field_library_homepage.value }}?
    – leymannx
    Commented Feb 25, 2021 at 19:20
  • What are the Slick settings? I think it's those settings that you need to look at because it's Slick plugin doing the output, you have to work with it instead of trying to come up with your own HTML. Maybe you just need to Rewrite the Image field to a link similar to what you posted, and "feed" that Rewritten field to Slick.
    – prkos
    Commented Feb 25, 2021 at 23:13
  • Likely because {{ field_library_homepage }} equals <div class="something">http://external-site.com</div>. Thus, you have markup around your url text. You can remove the markup by following my answer
    – No Sssweat
    Commented Feb 26, 2021 at 12:58
  • @leymannx In Views, it explicitly states that the value is {{ field_library_homepage }}. @prkos There is a link setting in the Slick config. If I choose it, it prints the URL and makes it clickable but doesn't make the image clickable. @NoSssweat In Views, I have that field set to URL Only and Show URL as plain text.
    – Chanel
    Commented Feb 26, 2021 at 15:18

1 Answer 1

1

I found the solution. In the Slick settings, I set the Link to the custom text field. For most of the time I've been working on this that field did not show up in the Link dropdown. But suddenly it did.

enter image description here

At first it's misleading because the Views preview shows the original image with the smaller linked image overlaid. However, if you go back to where the block is placed, the images will appear correctly. Whew!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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