Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [relations]

Questions around Craft's relational field types.

1
vote
2answers
29 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
24 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
48 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
46 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
27 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
29 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
32 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
0answers
24 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
38 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
46 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
45 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
42 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
29 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....
0
votes
1answer
345 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
26 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
149 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
11 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
28 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
44 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
52 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
23 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
16 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
60 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
48 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
23 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
50 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
28 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
190 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 ...
3
votes
1answer
222 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
vote
1answer
34 views

Many To Many Plugin Template Help

I am using the Many to Many plugin and wondering if the below is possible. I have a channel called Model ID. Model ID is then related to two other sections, Memory and SSD. I want to be able to link ...
1
vote
0answers
35 views

Check the field type of all the attributes of an entry

Here's the whole picture: I'm trying to make an API endpoint which should output everything from an entry: First I did this: public function transform(Entry $entry) { return $entry-...
1
vote
2answers
98 views

Relating to Solspace Calendar Events

I'm using Solspace Calendar for events, I also have a standard channel for reviews. What I need is the ability to connect the review with the event. Solspace offers "Calendar Events" custom type ...
4
votes
1answer
268 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 "...
1
vote
1answer
261 views

Combining Multiple Relation

I am trying to accomplish targeting but wondering if there is a way to combine these two? I took a look around and in the Craft 3 docs but I am a bit turned around on this, really would appreciate ...
0
votes
1answer
42 views

What is $source and $sources in BaseRelationField?

I see the following in BaseRelationField: public function settingsAttributes(): array { $attributes = parent::settingsAttributes(); $attributes[] = 'sources'; $attributes[] = 'source'; ...
1
vote
0answers
93 views

Order Entries by Category Fields (with fallback)

This is almost a duplicate of this question I have a section which I want to sort by category field. But the categories are not mandatory. When I apply |group('refSorter.first().title') it will ...
1
vote
1answer
844 views

Relational query get error “Getting unknown property”

I built up a plugin and inside the plugin I created the relation between Entry and Section using ActiveRecord, like below: In SectionRecord : class SectionRecord extends ActiveRecord { public ...
1
vote
1answer
16 views

List users connected to me

I have a relationship field within my member profile. It allows users to connect to each other, i can list those that currentUser is connected to, but i need to list all other members that are ...
3
votes
1answer
80 views

Find structure entries which parents relate to other entries

I want to select all children of all entries that fulfil specified relation parameter. I have tried this, but I think .isDescendantOf only supports single entry. Is this even possible? {% set ...
0
votes
0answers
45 views

Complex Relations

I've got a pretty complex relatedTo situation and I can't figure out if it's possible in Craft. Admin users have a field called "Admin Location" which is a Category field type, and may have more than ...
3
votes
1answer
105 views

Find entries from related section after certain date

Does anyone know how to achieve the following in Twig with Craft 3: My sections locations and trainings. I want to find all the entries from locations which has a relation to trainings and a ...
1
vote
1answer
72 views

One select search for Users in user.group

I'm a complete newby on Craft CMS and twig templating so please bear with me. I currently have a users base which I want to filter by category (a custom field) This would be my only input search ...
1
vote
1answer
109 views

Get relatedTo from Neo field

In channel A, we have a Neo field with a couple of different block types, in 1 of those types we have an entries field with channel B entries. On the channel B entry, I'd like to find out if it is ...
1
vote
1answer
105 views

Building a filtering system using both OR and AND relations

I'm trying to set up a filtering system similar to the one found on the product pages on asos.com. That system has different category groups of filters, where selecting multiple filters inside a ...
1
vote
2answers
123 views

How can I work with related entries within a Matrix in a plug in?

I have a Matrix field named "skillLevels" with a single block type. Each row has 2 fields, "skillName" and "skillLevel" skillName is a relationship to another entry (Skills) skillLevel is a simple ...
1
vote
0answers
80 views

Using target element criteria to filter results

I'm using the Element API plugin to try and search for addresses using minimum and maximum lat & lng values and then using target element within the criteria parameters to filter the results ...
1
vote
0answers
17 views

Can I use relational parameters that query as items on their own?

I am running a craft site on craft 2.6.2997 and latest craft commerce. I am building a url query that allows the user to add query params to the url with a bit of js. The url structure is as follows ...
1
vote
1answer
34 views

Search for non-existing tags shows all entries

I have 3 groups of tags that redirect to the same template. tags/index.html. All the routing and linking those tags to their group page works well. <a href="{{ siteUrl }}taggroup/{{ tag.slug }}" ...
2
votes
0answers
103 views

Filtering products by categories and showing number of products related to selected category

I currently have about 420 products and over 100 of categories to choose from for each products, showing the list of categories and filtering it, works fine, and performance is not too bad when it's ...
1
vote
1answer
47 views

Filtering by cousins

I want to do exactly this: Multi-step & bi-directional relations with relatedTo (#1640) Common example: Let’s say you have Books, Authors, and Publishers, and two relationship fields on the ...