Score:0

Pass parameters from block to a JSON endpoint using taxonomy term from URL

pk flag

I've been searching for a solution to being able to pass a taxonomy term on a views block that is on a given page using the term name that is in the URL. I agree with my team that it would be a best practice to have one block that can be placed on multiple nodes to pull relevant data from a JSON endpoint, on another server, rather than have a proliferation of one block for term.

Example endpoint URL remotesite.com/cars -- this would return the JSON result for all cars, while remotesite.com/cars/studebaker would return the JSON result limited to Studebakers. Example local node URL localsite/cars would list all cars available and would not need a filtered result while localsite/cars/studebaker would need the filtered result. "studebaker" is a term in the car-manufacturers taxonomy.

We are running Drupal 9.2.0 on the local development server, and have JSON:API installed and enabled,Views JSON Source, installed and patched and enabled, as well as Views Taxonomy Term Name Depth installed.

I haven't found in my searches anything similar to what we hope to accomplish. Can someone point me in the right direction? Is there a better way to do this other than by using Views and related blocks?

Kevin avatar
in flag
Are these taxonomy pages? Did you try using the term from the URL as a contextual filter?
user3486857 avatar
pk flag
These are on basic page content type nodes, not on taxonomy term pages.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.