Skip to main content

Questions tagged [relations]

Questions around Craft's relational field types.

44 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
661 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 ...
ScriptDev's user avatar
3 votes
0 answers
296 views

Getting related entries along with entry using the Element API plugin

I want to list all the related entries to the entry I am displaying using the Element API plugin. I have a channel called series and another called episodes, the episodes have a relationship with 1 ...
zizther's user avatar
  • 449
3 votes
0 answers
510 views

How can I use the ElementAPI to get related entries based on two parameters?

I can successfully get entries related the "normal" way, but my list of possible results are getting quite large. Currently I am returning html mixed in with the data. It's obvious I need to get just ...
Damon's user avatar
  • 4,706
3 votes
0 answers
206 views

How do I traverse relationships when populating models from queries?

I have three models / records - Journals, Issues, and Articles. Articles each BELONG_TO an Issue. Issues each BELONG_TO a journal. Issues have a date on which they've been published, and I am trying ...
Brett Bender's user avatar
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
2 votes
0 answers
173 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 ...
Aaron Bushnell's user avatar
2 votes
0 answers
162 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 ...
pinksorceress23's user avatar
2 votes
0 answers
132 views

Can't seem to get reverse relational field working from within a Neo field

Has anyone managed to get reverse relations from a Neo field working? I have a Neo field containing an Entries field which works fine on the page/section entry where I have the Neo field, but I’m ...
richardpixel's user avatar
2 votes
0 answers
227 views

Sort entries by related entry title

I’m trying to sort entries from a section called exhibitions by startDate and then by the title field of a related gallery entry. So exhibition entries with the same entry.startDate are ordered ...
periodical's user avatar
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
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
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
700 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 ...
Benjamin Kohl's user avatar
1 vote
0 answers
263 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 ...
Terry Upton's user avatar
  • 1,894
1 vote
0 answers
289 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 (...
Neokoenig's user avatar
  • 131
1 vote
0 answers
238 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 ...
bastiaanwuisman's user avatar
1 vote
0 answers
15 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 ...
Damon's user avatar
  • 4,706
1 vote
0 answers
212 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 ...
Dave Driesmans's user avatar
1 vote
0 answers
32 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 ...
James White's user avatar
  • 1,171
1 vote
0 answers
106 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-...
Jorge Anzola's user avatar
1 vote
0 answers
229 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 ...
KSPR's user avatar
  • 3,786
1 vote
0 answers
150 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 ...
user311's user avatar
  • 21
1 vote
0 answers
21 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 ...
M dunbavan's user avatar
1 vote
0 answers
102 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 ...
Simon East's user avatar
1 vote
0 answers
75 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 ...
Shanan Galligan's user avatar
1 vote
0 answers
87 views

Output Only Entries from Entry Field Related to a Category

I have a section called "lunchMenu" that contains an entries field ("menuItems"). Each entry in "menuItems" is related to a category in the category group ("foodCategory"). I would like to loop ...
Chris H.'s user avatar
1 vote
0 answers
58 views

Filter conditions on related UserModel in custom Record

My plugin has a custom ResponseRecord with relations to a UserRecord and ElementRecord as follows: public function defineRelations() { return array( 'user' => array(static::BELONGS_TO,...
Frank's user avatar
  • 153
1 vote
0 answers
232 views

How to display a nested list from a structure section based on categories assigned to last descendant?

I have a structure section, which allows categories to be assigned to the final descendant. I'm trying to list the entries by category, whilst including the parent structure entries (so the hierarchy ...
Andrew F's user avatar
1 vote
0 answers
63 views

How do I filter / restrict entries field in CP with a category

Is there a way to restrict the entry field type to specific categories? For example when adding a new field with type "Entries" to select the categories from where entries will be available. I found ...
Evangelos's user avatar
1 vote
0 answers
107 views

Exclude output of entries/users/products if category relation has particular field value

So basically what i have is a big set of categories (about 86 total, multi-level). Within my category fields i have a lightswitch with the handle 'private'. I would like to know how i would write a ...
Christopher Healey's user avatar
1 vote
0 answers
337 views

Relating to multiple categories?

Bit of an odd one here I can't quite work out. It's late and my brain is melting. I am creating an Artist listing page. It is a Single where the client can pick which category of Artist they want to ...
Matt Wilcox's user avatar
  • 3,209
1 vote
0 answers
81 views

Entries relation

I have two entries, let's say A and B. In the B entry I can select multiple A entries in a entries field. I want to get B entries that have specific A entries selected. So i have the code: {% set ...
Vlad Bozdog's user avatar
1 vote
0 answers
153 views

How to pull out entries related to multiple nested categories?

I have a category set up with nested categories so: Level1 -level2 -level3 In my entries channel each entry can have multiple nested categories so we may have an entry with: cat1 -...
Lettie's user avatar
  • 2,033
1 vote
0 answers
291 views

Is there any way to create reciprocal related entries?

I'm working on a sign language dictionary project. Each individual sign (or word) is an entry. I want to be able to have an area that shows words that are similar to the word that is being currently ...
Justin K's user avatar
  • 309
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
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
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
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
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
0 votes
0 answers
91 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"...
MISC's user avatar
  • 1,019
0 votes
0 answers
131 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 ...
Matt Wilcox's user avatar
  • 3,209
0 votes
0 answers
64 views

Events pages that are linked to venues crash when the venue entry is disabled

I have 2 channels, "events" and "venues". Using the entries fieldtype in the "event" entry a "venue" where it takes place is selected. However, if the venue entry is disabled, rather than the event ...
Shealan's user avatar
  • 264