Questions tagged [relatedto]
The relatedto tag has no usage guidance.
126
questions
0
votes
1
answer
31
views
How to filter elements by multiselect field via relatedTo
I have a "Tasks" section. Each entry in this section has a multiselect "Year" field and a category selection field.
How do I filter by these fields via relatedTo?
I'm trying to do ...
0
votes
0
answers
34
views
How in Craft 5 how do I query for related entries that are related from within a matrix field in a matrix field (nested matrix fields)?
In Craft 5 how do I query for related entries that are related from within a matrix field in a matrix field (now entryTypes) (nested matrix fields).
I want to show all related models for a product.
...
1
vote
1
answer
61
views
relatedTo craft 5 nested matrix entires
Im trying to query a list of matrix entries that have a related field but it doesn't work after updating to craft 5. Note that 'category' is not category field type, its a regular structured entry ...
0
votes
0
answers
24
views
Query relatedTo category or empty field
I'm not able to query a list of items relatet to a category or if category field is empty in the same query. I have to make two and merge them.
Is it not possible?
This works:
{# Fetch entries related ...
1
vote
1
answer
50
views
Relations query with OR: Find entries based on (lightswitch = false AND relatedTo()) OR (lightswitch = true) / nested relatedTo?
I have the following challenge:
we have a news channel for multiple company locations.
Some news should be visible globally (for all locations), but some news are only visible for location X.
But ...
1
vote
1
answer
66
views
craft.matrixBlocks - related to entry
I've got classes by entry and each week is a matrix block inside that week. I'm then outputting all weeks together using this query
{% set startDate = date(now)|atom %}
{% set classes = craft....
0
votes
0
answers
33
views
Matching entries against category custom field
I have two channels, pages and products and category groups for categories and regions.
The pages entry type has a field where you can select entries from products based on their category and region.
...
1
vote
1
answer
95
views
Looping through Entries that Match Criteria with Fields inside the Same Entries
I've been having trouble figuring out how to query my entries for another template. Currently, I have a channel of entries for "programs." These programs have a super table that contains a ...
1
vote
1
answer
26
views
Date of latest (parent) related entry?
I have a few sections whose main purpose is to be related to other entries - think authors' names, so a user can click through to all their entries.
On the templates for these pages - as well as tag ...
1
vote
1
answer
246
views
GraphQL - Optional relatedTo value
I have a component which lists events and can be configured to filter by category.
Query:
query Events($filter: [String]) {
entries(
section: "event"
relatedToCategories: {group: &...
1
vote
1
answer
168
views
How best to merge an array into an array for a relatedTo query parameter?
I have 3 Matrix fields which define optional parameters for building a query:
A related Entries field
A Categories field
A Tags field
Any combination of them could be used, including none or all.
So ...
0
votes
1
answer
244
views
Sort entries by separate related entries count
I am working on a sprig board that filters out Lessons from a structure in Craft.
This screenshot better illustrates this and how it works.
The main table is built using the following:
{# Sets default ...
1
vote
1
answer
144
views
Fetching entries that are related to 'not null'
I have a channel with Authors. Not all of them are used right now, so I'm trying to construct a query that will fetch all Authors are are related to some article.
This is what I've tried so far:
{% ...
1
vote
1
answer
42
views
Why is my relational query returning zero?
I have an entries page structure section
Pages
And two structure sections / menus
Menu A
Menu B
Menu A and Menu B have an entry field link called 'entryLink' that is a relation to an entry in the page ...
1
vote
1
answer
582
views
Get parent entry from child entry where relationship is in parent matrix field
I have a parent entry with a matrix field and one of the blocks has a relationship to a child entry.
How do I access the parent entry from the child entry page?
tried this, where eddChapter is the ...
1
vote
1
answer
362
views
Get entries which are not related in to another section
My scenario is I have entries in sectionA these are related to entries in sectionB.
I want to be able to show all entries from sectionA which are not related to any entry in sectionB.
SectionB has an ...
2
votes
1
answer
408
views
Set parent-child relationship in PHP
I'm new to Craft but long time back-end php programmer. I'm trying to assign a parent-child (a ENTRY type to another ENTRY type) relationship in php based on some business rules.
I've got my child ...
1
vote
1
answer
134
views
Optimize relatedTo query
Given:
Channel: Nutrition. 550k entries. It has entries field pointing to the "restaurants" channel.
Channel: Restaurants. 300k entries.
I'm trying to display restaurants that have at least ...
2
votes
1
answer
140
views
How many levels will RelatedTo work? In Reverse?
The TL;DR summary: if I have a related Entries field that I access, can I then access an Entries field within that entry?
I created a learning project running on MAMP to help me learn Craft, and one ...
2
votes
2
answers
165
views
Change link to entry if it's related to another entry
I have a section of reviews that has a selection of entries fields that relate to entries in other sections. For instance Product A Review might relate to Product A pre-release news.
On the review ...
1
vote
1
answer
46
views
How can I make an entries query based on currentUser is author or relatedTo currentUser
My project requires a notifications area. I want to list all notification entries that were created by currentUser or sent to currentUser.
I can do created by = craft.entries().section('thename')....
1
vote
1
answer
224
views
Order by reverse relationship count
It feels like I’m trying to do the impossible, but I can’t imagine this problem is unique to my project. Hoping someone here has figured it out before!
I have two channels, creators and products, and ...
2
votes
1
answer
554
views
Multiple relatedTo conditions using a combination of "and" and "or"
We're trying to make a filter that allows you to pick multiple items from 1 category, and multiple items from another category and return back all appropriate elements.
We're in PHP land not twig so ...
1
vote
1
answer
861
views
How to use Sprig's "Load More" Recipe After Update
This is a continuation of a previous question I had (Here). I am using Sprig's Load More Recipe. In my category page, I want the load more function to only pull up entries that equals the current ...
1
vote
1
answer
75
views
if entry has specific category, show specific html block
I have entries, which can have several categories.
These categories are in different categorie groups.
Now if i show an entry page, i want to display i certain html block
based on a specific category, ...
1
vote
1
answer
67
views
Display related entries on a category page filtered by another category field
I have a Structure called "Stoves".
Each Entry has two Category fields 'fuelType' and 'output'.
Fuel Type categories = ''Wood Burning','Multi-Fuel','Gas' and 'Electric'.
Output categories = ...
1
vote
1
answer
348
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
1
answer
109
views
How to get a list of unique related entries from within a related entries loop
Bear with me as I am not sure the best way to explain this.
But to try and summarise... how can I loop through related entries (locations) inside a a related entries loop (exams -> related to the ...
1
vote
1
answer
70
views
Showing Entries based on an Entries Field but also showing a slug in the url
I have a Channel 'Articles' with an Entries field which is linked to entries in 'Staff Members' channel. This is so that articles can be assigned to different members of staff.
I have the generic ...
1
vote
1
answer
217
views
Retrieve Matrix Field from Related Category in Element API
I have an API endpoint set up for a category group. This currently provides some details of all entries that have been assigned that category (i.e. related entries). That works well for some high ...
0
votes
0
answers
100
views
Search Results not working as expected
I have a search results page set up where there are a number of parameters in the query string used to filter results. I've got 3 out of 5 of these working and am stuck on the final 2.
My full ...
2
votes
1
answer
100
views
Pull info from a Related field within Matrix > within Super Table
Ok, my mind is about to implode with this… any help on template syntax very welcome!
I have 2 Sections: ‘artists’ and ‘schedules’
In the ‘schedules’ section I have a Matrix field called ‘...
1
vote
2
answers
201
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
1
answer
70
views
Additional criteria to filter status of field passed into RelatedTo
I'm trying to save all the images related to an entry in a variable. I need the images that are added through a matrix field in the entry. I'm using the following code, but am then also getting images ...
3
votes
1
answer
1k
views
In GraphQL how to query entries where related entry has a specific value
Lets have this query:
query test {
entries(section: "vacancies") {
title
... on vacancies_vacancies_Entry {
description
organisation {
title
... on ...
1
vote
2
answers
74
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 (...
0
votes
1
answer
47
views
Multiple Relations Trouble
I'm having trouble setting entries with multiple relations.
during testing I've hard coded the theme to 1 specific category
{% set themeID = "12309" %}
{% set theme = craft.categories.group('...
1
vote
1
answer
1k
views
GraphQL - Get related entries based on tags field
I'm trying to retrieve entries related to the current entry, based on a tag field called topics. Simple stuff.
Now, I use Craft's native GraphQL implementation so I'm bound to the possibilities this ...
1
vote
1
answer
69
views
order and limit the occurrences of related categories
I'm generating a list of all related categories of the entries listed on the page.
{% for entry in entries %}
{% set categories = craft.categories.group('functieGroep').level(2).relatedTo(entry)....
1
vote
2
answers
107
views
Sort entries by a related entry (lastName) and then paginate
I have two channels books and authors
I need to list all books sorted alphabetically by author. I have this working with the following code:
<ul>
{#
// loop through authors so we can ...
1
vote
0
answers
96
views
Showing entries in same category, excluding the current entry
I'm new to this, so sorry if this is really basic.
I want to display a list of entries in the same category as the main entry in my template, excluding the current entry.
This is my code:
{% for ...
1
vote
2
answers
240
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
1
answer
167
views
Get entries related to selected category only and not it's ancestors
The following is using commerce product entries, but I'm reasonably sure it could be any entry.
With the following category taxonomy:
- Category 1
- Category 1A
- Category 2
- Category 3
...
If ...
1
vote
1
answer
40
views
relatedTo a category in a matrix field
All, I'm very close, but missing something and any help is appreciated. I have a teamMember matrix block allowing me to add employees with some basic info. One of the fields is a category field called ...
1
vote
1
answer
106
views
Pulling blog entries related to a structure entry field type
fairly new to craftCMS. I've wrestled with this now for hours and exhausted all research avenues.
I have three main "service pages" (Web Design, Digital Marketing, Hosting & Analytics) These are ...
1
vote
1
answer
49
views
Display related entries on the entry page they are related to
I have a number of 'blog' channel entries related to various 'fayre' entries
I want to display all the blog entries related to the fayre entry page they are related to (Entry field is 'fayreBlog'), ...
2
votes
1
answer
301
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 ...
1
vote
1
answer
320
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
1
answer
504
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
2
answers
2k
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 ...