Replace tokens that link to taxonomy term pages with facet links?

Created on 17 September 2024, about 2 months ago

I have a few blocks that show on product pages showing similar products using a specific ingredient.

This ingredient is linked to the taxonomy term page but I would like this to go to the facet link instead just like it does on a manage display form.

Possible?

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom effortDee

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @effortDee
  • πŸ‡ΊπŸ‡ΈUnited States dcam

    I don't see why not. The ingredient is the taxonomy term, right? That doesn't sound like it would cause a problem to me. Is there a specific issue that you've encountered?

  • πŸ‡¬πŸ‡§United Kingdom effortDee

    I created the taxonomy term link in the header of the views block which shows related/similar foods based on the ingredients.

    How would I go about swapping this taxonomy term link, of which I used tokens, to a facet link to the same ingredient?

  • πŸ‡ΊπŸ‡ΈUnited States dcam

    Oh, I get it now. You're asking because the term isn't rendered, it's written into other text. I'd have to give it some thought. I never use tokens that much, so I don't have advice off the top of my head.

    The output of this module is a property of referencing entity, not of the referenced entity. So if this Views block displays the term data, then that's not going to work. We don't rewrite an entity's own URL and that's out-of-scope for this module. A new module would need to be written that could do that, though it's not a bad idea.

    So here's what I've gathered from what you've said:

    • This is a Views block.
    • The block is being displayed on a product page.
    • The view displays ingredient links. These other ingredients are similar to an ingredient that's in the product.
    • The views has a header. That header has text into which a link to a specific ingredient is written. This is the link that needs to go to the faceted search.

    Let me know if I understand any of that incorrectly.

    Given what I said before about the referencing entity having the facet link, that means we would need to work our way back to the Product entity in order to get it. In general, I wouldn't expect that to be too difficult. All you need is a View that displays Product data, filtered by the context of the URL. Then you output the product's reference field linked to the facet and rewrite it to have your header text around it. At that point you can use it as an attachment view for other views.

    The caveat to that is that you also need to filter that attachment view to a specific ingredient. You can pass other contexts to attachment views (I think), but I'm not sure how well that would work here. Also, I don't know how you give that original block that context in the first place. How does it know what your chosen ingredient is? That might help us figure out how an attachment view could work.

Production build 0.71.5 2024