Questions tagged [relations]

Questions around Craft's relational field types.

Filter by
Sorted by
Tagged with
0
votes
0answers
22 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
35 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
19 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
40 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
61 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
31 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
17 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
24 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
39 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
53 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
41 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 ...
0
votes
0answers
31 views

Craft 3 match all categories using relatedTo in a module controller

I am trying to perform an entry query using relatedTo to get entries that match all categories. I know how to achieve this with 'and' in twig but I can't seem to find the correct syntax to use in a ...
0
votes
0answers
29 views

Plugin development | Update/push relation to existing one, not override

I am currently trying to update entries for a user. The problem is: If i am saving a new relation, it's overriding the one before. My .csv customUserId customEnryId 22 1000 22 ...
2
votes
2answers
204 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
33 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. ...
0
votes
0answers
32 views

How to get category/entry url and a category url in entry breadcrumbs

I have entries for a channel called ‘resources’ that are related to multiple resource categories. When I call the category specific resource entries in a index, how can I get the url of website/...
1
vote
1answer
78 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
3answers
355 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
27 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
63 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
43 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
182 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
38 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
105 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 (...
1
vote
0answers
61 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
39 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
60 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
104 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
59 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
63 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
104 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 ...
0
votes
1answer
58 views

Displaying related image assets from another section with twig

I have a site that shows upcoming football matches in a table, and I would like to include the clubs' logos next to each club name. I have the following sections and entry types, both generated using ...
1
vote
1answer
41 views

Relation fallback if no category has been selected

I have a filter with a few different parameters that get pulled in and I was wondering if there was a relatedTo wildcard that I could use. Here's the relevant code: {% set function = craft.app....
1
vote
1answer
1k views

Craft 3 - Save new Entry with Relations (Categories/Assets)

i simply can not get my "job" done. I try to create a plugin for Craft, a simple one. It reads some date and should create new entries out of this data. First i stuck on a stupid save-mistake, someone ...
1
vote
1answer
51 views

Filter entries by other entry

There's a section called locations and another called vacancies. In vacancies the admin can assign a location entry to a vacancy. On the careers overview page we want to display selected vacancies ...
2
votes
0answers
419 views

Searching for Multiple Categories and Tags

I've been pulling my head for the past day on how to filter products with multiple categories. After a long search, I found and implemented on my project, Advanced Search with tags and categories It ...
1
vote
0answers
13 views

How can I use a double relation to include the currentUser as criteria?

I have a front-end form that allows registered users to edit content. In this case, it is a podcast. I have multiple podcasts that blog to different providers. Here is how I am selecting the provider ...
1
vote
1answer
39 views

How can I make related entries and globals part of the search considerations?

How can I make related entries and globals part of the search considerations? So I have a website search bar that searches the whole website. Within some jobs pages there are some global elements ...
0
votes
0answers
67 views

Indirect Relationship defined in Matrix Block

I have 3 channels: Reviews, Products and UseCases. In the section "Reviews" an entry has a list of "Products", based on a matrix field. Every block in this matrix field represents one listed "Product"...
1
vote
0answers
120 views

Sorting with reverse relationship

I have a overview page that combines with two sections (documentation and galleries). Those two sections are attached to a parent Event. So you can select in the event entry a gallery or a ...
1
vote
1answer
28 views

How to filter relational field types on their related content's status?

I have a Matrix field on Users. In that Matrix field is an Entries field. I need to pull all Entries from that field, regardless of the related Entries status. The following code returns Users but ...
1
vote
0answers
21 views

modifyEntrySources hook with reverse relations

Is it possible to do a reverse relation query in a custom entry source? https://docs.craftcms.com/v2/plugins/hooks-reference.html#modifyentrysources I have two entry sections, one called courses and ...
1
vote
1answer
95 views

Eagerload inverse relation

I would like to eagerload inverse relation. Business case: I have stories, stories are connected to books over relatedBooks field. Now I would like to query those books only which not have any story. ...
1
vote
1answer
71 views

SQL error when trying to use sortOrder on Matrix related block (Craft 2)

I'm getting the following SQL error when trying to simply order related entries in a Matrix block. Anyway around this? CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity ...
1
vote
1answer
27 views

CP: Title from relation?

I have the following 1:n relation between two sections: Source Element: Interview Target Element: Persons In the CP (only there) I need to be able to identify Interviews by the name of the ...
2
votes
1answer
80 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 ...
3
votes
2answers
35 views

Display Stores by Region with relations

I need display Stores by Region, by example: Alabama Store X Store Y Idaho Store A Store B So: I create two channels Stores and Regions. In the channel Stores I create a entries field type ...
2
votes
1answer
390 views

Is there a way to check if entry is selected in relationship?

This project has a lot of user stuff. I need to display display different sections based on if the current user is in a field. Is there a better/faster way than looping through and checking if every ...
5
votes
1answer
609 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 ...

1
2 3 4 5 6