Now we will create our next API, which is for exposing all the recipes under a recipe type:
We will have a new view created in the same manner, but instead of selecting Taxonomy terms, we will be choosing contents of all type recipes.
In the REST export settings, give the URL as
api/recipes/%
. The%
sign acts as the wildcard, which will recipe type tid as the argument.In the views settings page, we configure the view just like we did it for the recipe type. The fields that we will be showing are:
Node ID
Title
Publishing status
Recipe Type
Recipe Image
PrepTime
CookTime
TotalTime
Body
Ingredients
Instructions
Yield
Review
To get the recipes associated with a particular recipe, we will use the fields Recipe Type in the recipe content, which is referenced to the Recipe Type vocabulary.
In the advanced section of the views configuration page, under CONTEXTUAL FILTERS, click on Add to add in the Recipe Type tid as an argument:
In the...