Skip to main content

Questions tagged [relations]

Questions around Craft's relational field types.

Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

Filter GraphQL Response Based on Matrix Entry Type

In Craft 5, we now have a few Entry types with Matrix fields that can nest several other Entry types, or none. I'm struggling to work out a way to limit the returned results based on the content of ...
theAdhocracy's user avatar
0 votes
0 answers
21 views

Change layout of relations field in cp "Unable to find the template"

I've created a custom module that adds form submissions as relations to the entry they were submitted on. This functionality works, but I can't figure out how to change the template for the relations ...
Jane's user avatar
  • 11
0 votes
0 answers
41 views

Search Results - prioritize order by related field

I've got search working as expected on this site with the following code: {% set params = { section: 'inventions', limit: 10 } %} {% if searchQueryKeywords !="&...
CreateSean's user avatar
  • 1,983
1 vote
1 answer
57 views

Only show entries related to child category if it exists

I have a categories field for outputting products to a map. The categories linked to that field have a parent/child relationship. With {% set products = craft.entries.section('products').relatedTo(...
Tyssen's user avatar
  • 653
0 votes
0 answers
18 views

Whats is the correct way to save and retrieve an entry or assets in a custom record?

Let's say i have a custom ActiveRecord and want to save a single Asset or an Entry relation (one to one) inside one of it's columns, what's the correct way to do this?
user14370's user avatar
0 votes
1 answer
46 views

Issue with Multiselect field and related entries

I am having an issue outputting news stories that are filtered via a multi-select field, newsCategory is the the multi-select fied handle. Here is my code <div class="search-results search-...
bhackett's user avatar
  • 147
0 votes
0 answers
13 views

How to prevent advanced relation field setting «Relate entries from a specific site?» getting ignored?

I have a relation field with the advanced setting «Relate entries from a specific site?». When the user initially clicks on the field it works fine, on a second attempt the setting «Relate entries ...
Marco's user avatar
  • 11
1 vote
1 answer
55 views

Show related entries of a parent, where only a child of that parent is selected as a related entry

I use a structure section with two levels, parents and children. Is it possible to show related entries of a parent, where only a child of that parent is selected as a related entry? I did try to ...
Marcel's user avatar
  • 149
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. ...
Tyssen's user avatar
  • 653
0 votes
1 answer
20 views

reverse relation question in Commerce

I have a reviews section with an entry field to Commerce products. I'm trying to show the reverse relationship review on the product page. It appears to work when there are related entries but when ...
glider's user avatar
  • 647
2 votes
0 answers
30 views

Allow filtering elements by fields on related elements in element indexes

I'm trying to show some additional columns in the entry index, and allow editors to filter and sort by them. The problem is that the fields that need to be used for sorting are set on related entries, ...
MoritzLost's user avatar
  • 11.5k
1 vote
2 answers
80 views

Showing related assets referred to within Redactor (rich text) fields

When an entry includes a reference to an asset, like an image, that information is tracked and displayed. (The included screenshot shows where that reference would be, although this particular entry ...
4midori's user avatar
  • 656
1 vote
1 answer
50 views

Filtering entries via a table field inside a Matrix Block

James helped me with part one and it's working well: Filtering entries via a dropdown inside a Matrix Block Now I would also like to filter by a table field as well. The table is extras and the ...
bigdev's user avatar
  • 25
1 vote
1 answer
64 views

Filtering entries via a dropdown inside a Matrix Block

I have Entries with a Matrix field called events. I have an Entries field and a Dropdown field inside those Matrix blocks (block type event). I'm currently filtering by entry using andRelatedTo(['and',...
bigdev's user avatar
  • 25
0 votes
1 answer
62 views

Related entries: prevent duplicate results and order results by structure

I am building a shop with book titles, but most for book titles there is not only a book available for purchase, but there could also be a poster of the book, a bookmark and possibly other products, ...
Jolle's user avatar
  • 95
0 votes
1 answer
34 views

How to reference unique entries over different subsites and different groups?

We're investigating the use of headless CMSs for a health care and revalidation company. The website should consist of multiple subsites (specialized groups) which each have multiple localized content ...
Jeroen Boumans's user avatar
1 vote
1 answer
222 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: &...
Thomas's user avatar
  • 133
4 votes
2 answers
958 views

Craft 4: using the new laravel collections and related methods (in a performant way)

I am working on a website for a radio that publishes its programs as podcasts with episodes. Each of the 30 or so programs potentially has a lot of episodes. Each entry in the episodes channel has a ...
Jérôme Coupé's user avatar
1 vote
1 answer
137 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: {% ...
InanisAtheos's user avatar
3 votes
1 answer
577 views

Eager loading categories and assets inside related entries for gallery

I am looking for some advice on how to best streamline a gallery system on a site, but having trouble wrapping my head around the syntax needed to eager load nested asset fields with categories inside ...
sonoflee's user avatar
1 vote
1 answer
306 views

Query entries "with" entries that are actually related

I have a simple query: $paidFeatures = Entry::find() ->section('paidFeatures') ->type(['simpleFeature', 'customFeature']) ->with(['relatedEntries']) ...
Sean Delaney's user avatar
1 vote
1 answer
158 views

Allow drafts in entries field

Is it possible to allow selecting drafts in an entries field? Not drafts of an existing live entry, but drafts that aren't published yet. The only thing I found is an ElementCriteriaEvent triggered in ...
MoritzLost's user avatar
  • 11.5k
2 votes
1 answer
44 views

Sorting Categories/Entries by # of relations dynamically

does anyone know if there's a way to display a type of "most popular categories" list? It's not exactly my use-case, but it's very similar Essentially, I want to be able to have users search ...
Kevin Amézaga's user avatar
0 votes
1 answer
178 views

Find related entries by specific position in the entries field

I'm looking for a way to limit a reverse relations query to only match the first selected entry in an entries field. Some context: I have two entry types, institutes and offers. Offers have an ...
MoritzLost's user avatar
  • 11.5k
1 vote
0 answers
154 views

Order element query by number of related categories

I'm building an entry template that displays related entries to the current entry. To be related, an entry needs to be the same type as the current entry and share at least one category in one of two ...
MoritzLost's user avatar
  • 11.5k
1 vote
1 answer
129 views

Get raw/unformatted field values?

Is there a way to get raw/unformatted values for a field before they're passed to the field's normalizeValue function? That is, get the value close to how it's stored in the database? I haven't found ...
MoritzLost's user avatar
  • 11.5k
0 votes
0 answers
73 views

how to retrieve any/all related entries?

I have list of banks(institutions) that each one has branches. I'm using GraphQL API. By the bellow code I can get the branches with associated bank(institutions): query branches { entries(limit: ...
Nasser Ali Karimi's user avatar
1 vote
1 answer
133 views

Entries not being related

I am trying to query all entry elements related to a category but I am only able to get some of the entries to show up when I run craft.entry().relatedTo(category) I have a matrix field in the entries ...
Steven Zhang's user avatar
2 votes
1 answer
137 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 ...
doctorgloom's user avatar
1 vote
1 answer
200 views

Can't get a simple Reverse Relations for Entries field to work

I'm trying to get a simple Reverse Entries working, nothing fancy, but I'm stumped. I created a little personal project just to help me stretch and learn Craft better. I picked the NFL Draft just ...
doctorgloom's user avatar
0 votes
1 answer
117 views

Commerce search: return products containing keywords in related entries' fields

Craft CMS 3.6.11.2 / Commerce 3.2.17.4 We have a Stores structure section that contains fields (searchable) such as phone, address, etc. These Stores are assigned as Entries (searchable, max of 1) to ...
biko's user avatar
  • 670
1 vote
1 answer
268 views

Simplifying code using the new andRelatedTo param

I have the following code that works with Sprig. But with the new andRelatedTo param, I am wondering if this could be simplified? However, I am a little unsure if/where to start on this and how the ...
Terry Upton's user avatar
  • 1,894
1 vote
1 answer
56 views

Reverse related entry with Solspace Calendar

I'm using Solspace Calendar, When I create an event with it I use a related entry field called 'project' to choose an entry from a section called projects I can display the project title etc in the ...
user2569's user avatar
  • 457
1 vote
1 answer
214 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 ...
oscaralexander's user avatar
1 vote
1 answer
385 views

Element API, query entries where relationship field ':empty:' AND the same relationship field with specified entry ID

Element API, query entries where relationship field ':empty:' AND the same relationship field with specified entry ID. Can't seem to figure out how to do this without performing two separate queries ...
Bransin's user avatar
  • 117
2 votes
1 answer
148 views

Front End Search Related Entries

I have a front end search which is working fine when searching titles, however when searching for text in rich text fields, or an input field caseNumber or the title of a related entry there are zero ...
CreateSean's user avatar
  • 1,983
1 vote
2 answers
356 views

How to loop through multiple entries fields

I'm creating a dynamic side navigation where pages can choose which sidebar it wants to use. This is selected by an entries field called 'sidebar' - called in line 2. To create this I've made a ...
Jonathan's user avatar
1 vote
0 answers
42 views

Show parents of entry in custom entries field extending BaseRelationField

The default BaseRelationField shows only the name of the selected entry in the field (e.g. "SubEntryX"). I created a custom entries field by extending the BaseRelationField in a module. Now ...
Bobby's user avatar
  • 11
0 votes
1 answer
68 views

Get entries that aren't related to current user

I am trying to get all the entries that don't related to the current user via a user field. I have used the following code to fetch all the entries that do related to the current user {% set entries ...
LessMore Creative Studio's user avatar
1 vote
0 answers
28 views

Querying entries that have not been related to any other entry or contained matrix element

I have a large amount of content that we are attempting to collect before we migrate to our new site structures. Normally the staff are supposed to relate content back to main entries to make sure ...
Christopher Kennedy-Nuñez's user avatar
1 vote
1 answer
361 views

Localization Section propagation settings, and related entry field setting "Manage relations on a per-site basis"

Craft 3.4.20. Site is running multiple localizations Sections: Blog Post Propagation method set to, "Save entries to all sites enabled for this section" Blog Category (Structure entry with ...
Bransin's user avatar
  • 117
1 vote
1 answer
68 views

Entries relations with additional fields

I'm searching for a way to have additional fields on relations. The simplest exemple would be; you have stores entries and products entries, and you want to create a many to many relationship with the ...
Antoine's user avatar
  • 157
1 vote
2 answers
50 views

Display entries which share tags (2 or more)

I need to be able to display entries (within one section) that share keywords. I don't care what the keywords are, just want to display the entries based on 2 or more shared keywords. Anyone know how ...
richardpixel's user avatar
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 ...
Lukigi's user avatar
  • 565
1 vote
1 answer
44 views

Relationship all to all

I'm trying to pair all my custom product entries to all my dealers with 2 extra fields per product: price per day and price per week. The condition is that all my products are paired to all my dealers ...
Dirkv01's user avatar
  • 33
1 vote
1 answer
46 views

Bulk selecting Members and then including them in an email to another specific Member in a different member group

I'm wondering if the following is possible within CraftCMS and suggestions for making it happen? We have two Member groups (Customers and Contractors). When a Customer makes an enquiry they complete ...
Martin's user avatar
  • 1,203
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('...
CreateSean's user avatar
  • 1,983
1 vote
1 answer
427 views

Entry Search Unbearably Slow

Anyone have any tips on speeding up entry searches? Ours are currently taking about 90 seconds per search. Some stats about our Craft database: Entries: 336,000 Relations: 4,390,000 (!!!) Search ...
Tony DeStefano's user avatar
1 vote
1 answer
251 views

Categories or Structures: Most efficient way to organize FAQ sections

Working on a plan for a site that has multiple audiences, with a FAQ section for each audience. FAQ entries are organized by Topic (Finance, Advertising, Publicity) each FAQ entry can be ...
sonoflee's user avatar
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 ...
CreateSean's user avatar
  • 1,983

1
2 3 4 5
7