KreativePro Masterclass
Hello, {first_name}
4.4
Related Entries
Learn to Build Websites with Craft Cms
Completed
Oops! Something went wrong while submitting the form.
Completed
Browse Lessons
38
lessons
4
hours
MINUTES
2
files
Level

Access our premium community including bonus tutorials, project files & weekly resources.

UNLIMITED ACCESS
Overview

Filter Related Entries

On this Craft Cms lesson you'll learn how to query related data in your templates.

Reviews

Manases
Being the best means investing in the best, no matter what level you are at, this course will take you through the entire process you need to be able to implement an idea and turn it into a fully functional business.
Manasés Padilla
Photographer & Entrepreneur
Noel
It has been the best investment I made in my design journey so far. I would consider myself a novice but I honestly feel like I've gained a genuine professional insight into the process of creating a high-level website.
Noel Hale
Founder of Slush Monkeys®
Mae
I'm an early adopter of the KreativePro Masterclass, and I love how well put together it is. Neftali takes you through each step of the process from paper sketches to marketing all with fun visuals & clear instructions!
Mae Green
Product Designer @ Dropbox

All right, guys. Welcome back to another lesson on Craft CMS. On this one, I just want to go over some of the ways we could filter related entries. And what I'd like to do is output all the related movies of this particular actor. Under the movies template, we're going to grab the grid. So if we toogle open the grid, we're going to see all that little snippets of code.
We're going to bring that over and then select it and copy it. And we're going to bring it over underneath the cast slideshow. We can remove those paginations, we don't need that. And for the conditional or the entries, we need to call it a new variable name because we're calling entries on movies. But in the cast now we're trying to fetch all the movies that are related to this particular actor.
Right. So in order for us to do that, we need to create a variable called related movies and call in craft entries. So the objects craft, and then the section to handle movies and just output all of the results. So let's swap out the title. So it should be "known for" in this case, the actor is known for, and let's change the variable in our for-loop to the one in the top of the document related movies.
So if we refresh, what's happening is now we're pulling absolutely every single movie. So the same idea from the movies template, but what we want to do is filter it by the actor. The way we do that is on the variable itself. So let's go ahead and add in the parameter called "related to", and inside of that, we're going to add in the entry object.
And as we know, the entry is the dynamic information of this actor itself. So we can see now, Elijah Wood is related to all these Lord of the rings movies. Awesome. .

‍

Coming Soon

Designers ultimate weapon of choice
38
lessons
4
hours
MINUTES
2
files
Level
Digital Media Masterclass by Neftali Loria

Neftali Loria

Author & Instructor
@kreativepro
KreativePro Masterclass Bundle

Access our premium community including bonus tutorials, project files & weekly resources.

UNLIMITED ACCCESS
PRICE INCREASE:
00
Days
00
hrs
00
mins
00
secs
🚀