Stack Exchange Network

Stack Exchange network consists of 174 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
0answers
15 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
12 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
9 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 ...
0
votes
1answer
26 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
29 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
15 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
29 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
21 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
23 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
52 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
25 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
16 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
37 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 ...
3
votes
1answer
91 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
79 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
0answers
25 views

Importing entries under a parent with Sprout Import using related key?

When creating the import JSON for Sprout Import, is there a way to use the "related" key in the attributes section of a new entry to attach the entry to a parent? I see in another question that you ...
0
votes
1answer
25 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
33 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
284 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
14 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
64 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
33 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
52 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
54 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
63 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
45 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
113 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
56 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
12 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
25 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
62 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
41 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 ...
2
votes
1answer
42 views

Associate child categories only to an entry

When adding a Categories field to a section, if you select only child categories, Craft automatically selects the parent categories too. I emailed Craft support about this and they explained it's by ...
3
votes
2answers
161 views

Query entries relatedTo multiple categories in controller

I have an AJAX GET call that should count all the products matching three different taxonomies. Product families Sectors of application Liquids suitable for the product so in the form the user ...
0
votes
1answer
28 views

Merge related entries from several matrix blocks while maintaining other matrix field data

I have a matrix that essentially creates categorized lists of other entries. The fields in my matrix block are "categoryName", a plain text field and "member", a entry relationship field. I know i ...
2
votes
1answer
146 views

Why isn't relatedTo not working (anymore)?

I’m using a structure for creating new pages and navigation. In this structure there are multiple entry types where one is used for creating category pages. Here a user can add some content and select ...
4
votes
1answer
94 views

How do I query two relationship fields where one relationship MUST be empty?

I have two relationship fields. I am trying to query all entries where the first field is related to a particular element and the second field is related to nothing. Here is how I thought it would ...
2
votes
1answer
46 views

Smart Map - Output map locations from relationship file in a matrix

I have "locations" section where each entry is a location, with a Smart Map field for the address. I have another section "pages", where I have a matrix field which contains an entry relationship ...
1
vote
1answer
57 views

Specify ‘primary’ entries in list of related entries

I’m currently redesigning a website for a scientific research institute that conducts research projects in multiple different areas, produces reports on those projects once they are complete, and then ...
1
vote
1answer
163 views

Can Craft Commerce products be filtered with multiple query params?

I am using Craft CMS 2.6.2987 and the Craft Commerce plugin. I am building a list of products on a page using query params. The idea is that there are 2 approaches. 1) A user clicks a set of ...
2
votes
1answer
192 views

relatedTo currentUser AND entry

I have channel X set up where it's entries have a "users field", an "entries field" (that are picked from channel Y) and a whole bunch of other data with regards to the how a defined user has ...
2
votes
1answer
37 views

Can I set the same relation in a field multiple times?

My customer wants a videoplaylist for users. Idealy I'd like to have a assets relation field for the playlist and relate all the videos in said playlist. The problem is if a user wants the same ...
1
vote
1answer
280 views

RelatedTo query with length criteria

I am trying to get results from a relatedTo query, but only if there are more than say 1 results. Right now I am using two queries to achieve this, like so: {% set authors = craft.entries({ ...
3
votes
1answer
39 views

Listing all entries which belong to an entry

Trying to list all the entries which belong to an entry. Currently I have the following field format: Product Has an 'retailer' entries field. Retailer Normal entry. On the retailers _entry.html ...
1
vote
1answer
371 views

Frontend form with relation to an entry

I have a field called "assetId" from Entry "A" with Field Type "Entries" and Source "B". How can I build a form so that a relation between these two entries will be established. In the craft backend ...
1
vote
0answers
54 views

Relating entries/users with a custom element (or custom database table)

Let's say I have a bunch of Craft entries and Craft users that I need to relate to another custom database table. How would one approach this? Would I be correct in thinking that my plugin will need ...
1
vote
1answer
147 views

Related Entries

I want to glue entries together across multiple sections. My first thought is to use fields that are entry related, like blog would have the fields news, tutorials. The tutorials section would ...
1
vote
0answers
39 views

Display entries linked from Matrix field according to the entries' structure and a light switch in the Matrix

In a channel (market), I have a Matrix field (market_products) with a Stucture-based Entries field (products) and a Lightswitch field (active/inactive). For each market, I need to create an ordered ...
2
votes
1answer
44 views

Craft entries statements failing

I'm try to use related entries from different channels to display content on a home page. Using the code following with "selectNews" as a entries fieldHandle in the Home Page: {% set entry = entry....
4
votes
1answer
160 views

Categories within matrix for relatedTo

I have a matrix field with a category field. I need to group these matrix items by category and give them headings which I'll use for tabs. This is how I'd do it for entries but is it possible for ...