Questions tagged [relations]

Questions around Craft's relational field types.

Filter by
Sorted by
Tagged with
2
votes
1answer
24 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 ...
0
votes
1answer
37 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 ...
1
vote
0answers
27 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 ...
1
vote
1answer
22 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 ...
0
votes
0answers
34 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: ...
1
vote
1answer
23 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 ...
2
votes
1answer
50 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 ...
1
vote
1answer
44 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 ...
0
votes
1answer
27 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 ...
1
vote
1answer
53 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 ...
1
vote
1answer
25 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 ...
1
vote
1answer
46 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 ...
1
vote
1answer
144 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 ...
2
votes
1answer
57 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 ...
0
votes
0answers
23 views

Load category values based on another category field

I'm really new to Craft CMS, I have a site where I need to do something like this: There are 2 categories, Brand and Model (Models have a relation to Brands via category field). In entries I have 2 ...
0
votes
0answers
17 views

Problem with entry relations in using craft + postgres

I have a custom module saving entries into the system and those entries contains several category relationships. I have done the same previously with MySql and never had problems. I am currently ...
0
votes
0answers
9 views

How to pass extra filters to products field type?

We are adding a 'Featured products' field to a category fields config and we're looking to filter the list of products that are selectable by the category this field is appearing in. For example, if ...
0
votes
0answers
40 views

Total count of entries related to entry from another section (structure), including all levels within that section

I have two sections: Products (channel) and Accessories (structure). The Accessories section is a structure and can multiple levels to it, a Product may relate to a child (level 2) but not it's parent ...
1
vote
2answers
58 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 ...
1
vote
0answers
23 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 ...
0
votes
1answer
44 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 ...
1
vote
0answers
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 ...
1
vote
1answer
132 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 ...
1
vote
1answer
29 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 ...
1
vote
2answers
45 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 ...
1
vote
0answers
275 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
1answer
37 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 ...
1
vote
1answer
30 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 ...
0
votes
1answer
34 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
1answer
129 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 ...
1
vote
1answer
141 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 ...
1
vote
2answers
59 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 ...
2
votes
2answers
388 views

Craft 3 version - How to get entries related to current category only (not children)

I need some help with syntax on this for Craft 3, please. I want to use this piece of code: {% set fruitEntries = craft.entries.relatedTo({ relatedTo: catP,id: 'and, not '~str }) %} from this ...
1
vote
1answer
43 views

Grabing data from another channel associated to an entry displayed using category

I have a page that shows a listing of entries (called products) by category. Those product entries have related content (reviews) stored in another channel that are tagged using a relations field. ...
1
vote
1answer
258 views

How do I flush the query cache?

How do I flush Craft's query cache so that I may query a relationship field again in the same web request with a new set of parameters? In this particular scenario, I need to handle it inside of a ...
1
vote
4answers
865 views

With a categories field, how do I query only the *selected* categories?

Suppose we have a category group that allows for any number of levels to its structure. We also have a category field that allows for choosing any number of categories from that group. In our example,...
1
vote
0answers
125 views

Adding Product Variant and Related Product to the cart together on Craft Commerce 2

I want to add a product variant as well as a related product (chosen from a select list) together when the user clicks the add to cart button. I can see you can add multiple products together with ...
1
vote
1answer
80 views

relatedTo - return only entries that have a related entry where a field in the related entry has a value

Trying to figure out if this is possible in 1 step. I want to return locations that have a related entry in the relatedMerchant field, but I'd also want to make sure that a field in the ...
2
votes
1answer
116 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
2answers
593 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
44 views

How to include a lightswitch for each related entry in the source element of a relationship

I have a Services section in which I keep a related entry field for News. (News by Service) The News items to be displayed for each service are selected in a "News" entries field in the Service entry. ...
1
vote
0answers
151 views

Querying a supertable field

I have an entry type called people which has a superTable field called programmeAffiliations, with three fields, jobTitle, researchProgramme, primary where: researchProgramme is a category field (...
2
votes
0answers
104 views

What's the most performant way to get reverse related entries within an Element Query?

What's the most performant way to get reverse related entries within an Element Query? Here's a contrived example of this. I have thousands of "book" entries and thousands of "collection" entries. I ...
1
vote
1answer
42 views

Relations and Categories

What's given: Channel: Nutrition Entries Fieldtype: restaurant Category Fieldtype : menu Category: Menu Channel: Menus that also use relations using restaurant field. Each item in the nutrition ...
1
vote
1answer
81 views

Need help trying to pass a variable of a related entry

On my page, I have a form which is using Freeform (Solspace). I'm attempting to setup a custom redirect URL for the form. The form will apply to numerous entries in a channel and some will require ...
1
vote
0answers
144 views

How do I use a relation field in an element?

Currently I have a field that extends BaseRelationField, and 2 types of elements. I want the field on elements A to be able to select from elements B. So far the field itself works, which I tested by ...
1
vote
1answer
88 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
42 views

Relationship between channels/entries

I need some help. Really struggle understanding how to build relationships between channels/entries. Context/Want: I have two separate channels: 1. "Plant catalogue" 2. "Plant care" I want to re-use ...
1
vote
1answer
70 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, ...
1
vote
1answer
152 views

order by Table Number Field

% set entriesList = craft.entries.section('parks').relatedTo(entry.Line.one()).all %} {% if entriesList|length %} <div id="found-in" class="park"> <ul> {% for ...

1
2 3 4 5
7