In this example we’ll be building a view in Drupal 7 that filters for different recipes based on liquor brand (a content type) and product (another content type).
This will be a Page View. The path will be
1. Create the view as normal
2. Add a “Relationship” for the entity reference for “Brand”
3. Add a “Contextual filter” for Field: title
4. Click to open the Contextual filter that was just created.
Select from the dropdown the relationship to match the “Brand” relationship that was created in step 2.
Add a custom PHP snippet in the “Specify validation criteria” area:
$handler->argument = str_replace("-"," ",$argument); return true;
This code will allow for Brands with a space in the title field to render in the URL as a dash.
You can test this in the “Preview with contextual filters” of the View.
5. Repeat 2, 3 and 4 to create a Relationship for the Product entity reference field. The order of the items in “Contextual filters” is important.
6. The URL scheme for the recipe landing pages will be:
7. Feel free to reach out to us if you have any questions! Use the contact form here.