Questions tagged [relatedto]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
5
votes
1answer
676 views

Filtering multiple categories with URL queries

I am trying to filter using categories. I have to filters type and size, in the url. /products.html?size=medium,large&type=polo-shirt,jeans In my template, I am doing the following {% set sizes ...
4
votes
2answers
259 views

Most related articles

I am using the normal relatedTo property to find related articles, but I have an issue which is: craft.entries.section('section').relatedTo("tags").id('not ' ~ entry.id).limit(3) Lets say THIS ...
3
votes
1answer
478 views

Get related posts excluding current post in Craft 3

In Craft 3, I’m trying to get the five most recent other posts sharing a category with the current post. I got this far: {% for relatedPost in craft.entries.relatedTo(entry.newsCategory).limit(5) %} ...
3
votes
2answers
62 views

Showing a list of selected/related categories to entry

I have a suitability category field in my product type that allows the content writer to select which categories this product is associated with. But my issue is that on the product page I need to ...
3
votes
2answers
493 views

Reverse relationships with entries and users

I have a relationship between users and 'locations', and I'm using the code below to output some markers for a map. This all works fine except for two things: I'm repeating a couple of 'for' loops. ...
3
votes
2answers
545 views

Multiple category relationship criteria (or)and(or)

Is there a way to do relatedTo categories where the category is (a or b) and (c or d or e)? I can get (a or b) working using: {% paginate craft.commerce.products.relatedTo(categories).limit(20) as ...
3
votes
1answer
557 views

Craft 3 Element API: Query the “parent” entry of a “child” entry with Matrix blocks connected by an 'Entries' field

In a Matrix block field of a "page" entry, I'm using an Entries field to manually select a list of "article" entries to the "page" entry. When I query an "article" entry, is it possible to query its "...
3
votes
1answer
242 views

Categories within matrix for relatedTo

I have a matrix field with a category field. I need to group these matrix items by category and give them headings which I'll use for tabs. This is how I'd do it for entries but is it possible for ...
2
votes
2answers
40 views

Need a little help with basic understanding of how categories work

I am trying to figure out how I can put categories to use, and I need some help. I have created a category group called "group1", and 2 catogories inside called "cat1" and "cat2". and I have added ...
2
votes
2answers
1k views

How can I filter selected/related entries by their categories?

I have a section called "Events" and an Entries field, we'll call myEntriesField to select related entries from another channel called "Exhibitors" On the Events page, I need to display the related ...
2
votes
1answer
228 views

RelatedTo “and” and arrays

I have something I can not get my head around. This works as expected: .relatedTo(['and',{targetElement:22},{targetElement:33}]) But when I am building an array to use as relation criteria like so: ...
2
votes
1answer
118 views

SEOmatic not merging fields from a related entry

I have a pretty specific set up: posts get created via rss feeds and images are not attached to the specific posts, so instead in the entry template I use an image from a related entry. When I try to ...
2
votes
1answer
329 views

How to get all images from entries including Matrix field

I have a photo gallery that pulls in all entries and then finds the images within them and then displays them along with links to the entries that used that image. Except, it's not pulling in the ones ...
2
votes
1answer
291 views

loop through an entry's “related entries”, grouped by category

Hope somebody can help us with this: Objective: loop through a given Entry's "Related Entries" entry field and output the results - but group the results by the category to which they belong - not ...
2
votes
1answer
980 views

Mixed relation criteria operator in Element API

I have a bit complex filtering system that I try to replicate using Element API. So far I have this which works to a degree: Example url: training.json?reg=124&cat=99&prod=129&erp= '...
2
votes
1answer
41 views

Show on user profile page the commissions he is connected to

I have a commissions section in where we have a matrix field where we add the user (from craft.users) and the function of the user. A user can be in more that one commissions. On the user profile ...
2
votes
1answer
856 views

Passing Multiple Relation Criteria In Plugin

I have a channel (projects) that has two different entries fields (year & research theme), both of which I want to be able to search in a plugin. The docs for the relatedTo entries method show ...
2
votes
1answer
51 views

Getting entries from multiple categories

I have two categories, Annual Reviews and Publications. I want to get all entries from these and paginate them. The code I am using is fine for one category - both work individually, but as soon as ...
2
votes
1answer
212 views

How to fetch ALL users related to a field, including unverified/pending?

My users have a relationship field called Organisation. In my plugin, I am trying to fetch all users that are related to the organisation I pass it. BUT I would like ALL users including Pending, so ...
2
votes
1answer
87 views

How to exclude child elements when looping through categories?

I've got a few categories set up with a few child categories for each. Each one has assets (PDFs) assigned to them, by going into the assets, double clicking, and setting the category field there. So ...
2
votes
1answer
55 views

Can I get entries related to one category from a specific site?

If I can get entries in a category like this: {% set entries = craft.entries.section('sectionSlug').relatedTo('categorySlug').all() %} And a entries from another site like this: {% set entries = ...
2
votes
1answer
230 views

Combine Eager-Loading and relatedTo(category)

For a website I'm building for a client I've build a navigation where on hover an image changes dynamically to the image assigned to the entry. See this page for a better understanding: http://...
2
votes
1answer
435 views

relatedTo currentUser AND entry

I have channel X set up where it's entries have a "users field", an "entries field" (that are picked from channel Y) and a whole bunch of other data with regards to the how a defined user has ...
2
votes
1answer
178 views

Basic Relation save

I have two sections: Drinks Ingredients I have a relation/entry field set on the drinks. So for example, two entries in the ingredients section are related to a specific drink. My question: I ...
2
votes
1answer
443 views

List Only Child Categories Related to Entries

I need to show a list of Child Categories which only have Entries attached. From about 6 different solutions here, I have assembled the following. It works perfectly on a Section that has < 200 ...
2
votes
0answers
65 views

relatedTo doesn't seem to work when using multiple sections in a craft.entries call

I can do craft.entries.section('mySection').relatedTo(item.id) and it will return the result, so i assumed i could do craft.entries.section(['mySection','mySection2','mySection3']).relatedTo(item.id) ...
2
votes
0answers
115 views

Can't seem to get reverse relational field working from within a Neo field

Has anyone managed to get reverse relations from a Neo field working? I have a Neo field containing an Entries field which works fine on the page/section entry where I have the Neo field, but I’m ...
1
vote
3answers
78 views

Returning entries that contain both categories

I'm creating a filter and would like to return entries that must contain multiple categories (and behavior, not or). A sample url would be /events?cat=2,3. {% set eventCat = craft.request.getParam('...
1
vote
1answer
58 views

Fetch target entries that have been linked through an Entries field

I have a section Posts that has an Entries-type field called Authors that can be linked to one or more entries in section called People. To make a filter for my posts index, I need to fetch all the ...
1
vote
1answer
292 views

How to display number of entries for a tag and not display if no entries?

I want to be able to display the number of entries that have a tag. Like: Fruit (9) Vegetables (4) I also want to avoid displaying any tags without any related entries. My code right now looks like ...
1
vote
1answer
177 views

Get entries based on multiple fields in controller

I am trying to get the entries based on multiple fields. Fields can be of type tags, checkbox, radio box, and number. In my controller currently what I tried is. $extrafilter will be like Array ( ...
1
vote
1answer
378 views

Order entries by a category field alphabetically then paginate

I've tried so many different things and can't get this to work... {% set makeCat = craft.categories() .group('make') .orderBy('title') .limit(21) %} {% paginate makeCat as pageInfo, ...
1
vote
1answer
157 views

Commerce discount promotions as a fieldtype?

I'd like to create an entry in Craft that talks about a new discount, and then choose that discount via a field (so a bit like you can choose an entry or a product). That way, should the parameters of ...
1
vote
1answer
186 views

Merging Multiple Relations as params

I have the following code where I'm pulling entries related to another entry which works fine. However I also want to limit the entries returned on a category page and thus am merging in a relatedTo: ...
1
vote
2answers
236 views

Group entries by Category and then in each category by related entry field

I have a channel with categories and an entries field. I need to first group all entries by their category. This is working fine. {% set entries = craft.entries.section('publicationsChannel') %} {% ...
1
vote
1answer
361 views

cannot get relatedTo by slug only ID

Can someone tell me why I am going crazy and cannot figure this simple relatedTo issue out? So I have a categories section called Case Studies and several categories within. I am trying to filter the ...
1
vote
2answers
144 views

Get Related Entries and then filter those by specific category in url segment

Channels: Photographers Photos - entries field handle "photographers" - categories field handle "category" url structure where segment 2 is the photographer slug and segment 3 is the ...
1
vote
2answers
265 views

Filtering dynamic criteria with AND

I have a form that is set up to include multiple values with checkboxes. I pass all those values into an array {% set specsQuery = craft.request.getParam('specs') %} {% set productSpecsCategory = ...
1
vote
2answers
68 views

Show related entries grouped by category with category title and description

Anyone able to direct me on this? I have a page that allows you to pick related entries (cables) within the page I want to output the related entries (cables) but group them by their category. I have ...
1
vote
1answer
94 views

Selecting a subset of entries, based on a relatedTo call

I have a question about relations... or maybe its also about making queries. First I want to select a set of data, and then I want to select a subset of that data, based on a relatedTo call. If I ...
1
vote
1answer
68 views

Filter results by users contained in a Users Relations RelatedTo field

I would like to exclude entries from appearing in the template results that contain Users from specific User group. My code below works if all the User(s) in the RelatedTo field are part of the ...
1
vote
1answer
34 views

How to use categories with Sprig's “Load More” recipe

I am trying out Sprig's "Load More" Recipe and I am trying to call up entries that are related to the current category page. But when I add .relatedTo(category) to the entry model, it doesn'...
1
vote
2answers
40 views

Show only and merge the entries from multiple categories related to that entry

I want to show the entries which have same category of that entry. The entry might have multiple categories, so I want to merge the result. If there is a result, then only the whole structure will be ...
1
vote
2answers
39 views

Display entries sharing the same nested category on an entry page

I'm trying to show the other entries assigned to the same nested category (on an entry template) but get an error if I use .last() which I was hoping would show the nested category assigned entries (...
1
vote
2answers
36 views

Specific entry type in entry field

This seems like an easy question to answer but I can't seem to figure it out... I'm sure we could do it in Craft 2. Anyway, I'm trying to figure out how to only display a certain entry type in an ...
1
vote
1answer
86 views

Searching for item SKU in Commerce orders

I'm trying to show some Commerce 2 order information on the front-end. I can't work out the correct syntax. I'm trying to list orders that include a specific product. I have orders for item SKU "...
1
vote
2answers
245 views

Related To query

Struggling to get multiple relationship filtering working. So want to filter an entry (people) by one or more of the following: - location (entries) - specialism (categories) - team (categories) For ...
1
vote
1answer
66 views

RelatedTo relation - checking matrix block status is enabled

I need to search for all commerce variants related to a custom element "Account". The account element is related to a variant through a matrix field with handle varientaccountmapping, block handle ...
1
vote
1answer
193 views

Multiple and or relatedTo in plugin element criteria

I am trying to return entries that relate to a series of categories. For example, I am trying to return clothing, in this example, I want to return all entries related to (flannel or denim) and (blue ...
1
vote
1answer
66 views

Get entries related to same category

I have a channel (handle: "infopages") with entries. I have a channel (handle: "products") with entries. I have a category (handle: "productTypes") Every entry from "infopages" has a category field, ...