Questions tagged [relations]

Questions around Craft's relational field types.

Filter by
Sorted by
Tagged with
0
votes
1answer
33 views

Fetching Existing Users In Users Field Doesnt Work When entries.saveEntry Event Triggerred From Frontend

As the title says, I can successfully return the "existing user IDs" from an entry field if the "entries.saveEntry" event is called after saving the entry from the CMS admin area; however, if I save ...
1
vote
2answers
75 views

How, in a plugin, can I check that a User's “Favourite Entries” field contains a specific Entry?

Users in my project have a Favourite Entries field. In my plugin I want to check whether a specific Entry is present in that field for that user. I'm passing the Entry ID to look for. I am not ...
1
vote
2answers
704 views

Editing entry in front-end

I am trying to edit an entry automatically when you press a button. Is there a way to do this? A bit more detail: I have listed up a few entries, each with their own button. When I press the button ...
2
votes
1answer
236 views

Delete a relation in frontend form

We have a change profile page where members can choose out of the users table who of the other members is their mother (or father). Below my (simplified) user profile form <form method="post" ...
2
votes
1answer
117 views

Reverse relationship in Craft Commerce?

I'm working with Craft Commerce with a set of individual items in a product type and in another, I have packaged sets of the same. The sets (cardSets) have a relation field to select the required ...
2
votes
1answer
819 views

Passing Multiple Relation Criteria In Plugin

I have a channel (projects) that has two different entries fields (year & research theme), both of which I want to be able to search in a plugin. The docs for the relatedTo entries method show ...
1
vote
0answers
47 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,...
4
votes
2answers
163 views

How do I include record relationships in validation?

Say I have a record defining a foreign key relationship which is set to required, such as: public function defineRelations() { return [ 'type' => [ static::BELONGS_TO, ...
1
vote
1answer
157 views

Map one asset attribute field to another using MySQL

In Craft, is it possible to map one field containing string value to another? I have a bunch of image assets that has a title field and altTag fields. I've entered data into the alt tag field, but ...
3
votes
1answer
129 views

How/Can does Craft handle ancestor/grandparent relationships?

I spent a fair amount of time yesterday searching for any other questions that may have been answered that are similar to this one, but haven't had much luck. Essentially what I want to do is to ...
2
votes
0answers
178 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 ...
2
votes
1answer
413 views

Getting related models in templates?

I recently started learning plugin development for Craft CMS. I'm creating a plugin that deals with video content. For this example I'll use two models: MyPlugin_ChannelModel and MyPlugin_VideoModel. ...
1
vote
2answers
74 views

Displaying images from a matrix field from a related field

I have a section that is a single type. On this page there is a relation ship ('entries') field where the user can select a related photo gallery. Photo gallery is its own section with a matrix field ...
4
votes
1answer
319 views

Foreign Key column pointing to `craft_relations` table

I am writing a plugin with a Record. I want the primary key of the table to also be a foreign key relating to the craft_relations table. Ordinarily, I would add something like this... public function ...
2
votes
1answer
150 views

Show related entries that have the same Category, and some of the same tags?

I have succesfully shown some related entries that are in the same category, using the following: {% set relatedEntries = craft.entries({ section: 'blog', relatedTo: entry.blogCategory.first()...
1
vote
1answer
108 views

`saveRelations` returning `null`

I'm using the saveRelations method in the RelationsService to save entry relationships in a plugin I'm working on. Everything is working as expected, however, saveRelations is returning null on ...
2
votes
2answers
137 views

Restricting relationship field by author

First site using Craft and impressed thus far. I'm going to be allowing CP access for all users, and these users will have access to multiple channels. I want them to be able to relate their entries ...
3
votes
3answers
421 views

Get disabled related entry's data within plugin

I'm looping through products ($rawProduct) within Craft Commerce, within a plugin, and returning products which fulfill a certain criteria. I'm then returning a $products array of objects with the ...
0
votes
1answer
192 views

Showing related entries field

I have a section called Services. I have another section called Case Studies. For each Case Study I want to show which service is being used so I add an entry field and choose the right service. On ...
5
votes
2answers
267 views

List only Orders containing specific Products

Each Product has a Merchant field which is standard Craft User. What I'd like to do is list out all Orders which contain one or more Products relating to the currentUser. I was hoping I'd be able to ...
4
votes
1answer
286 views

Filtering on related entries (with an array query param)

I'm getting myself into a potential pickle here and wanting to know the best way to get apply filters on the current scenario: I have a central business section which is getting populated via an API (...
1
vote
1answer
399 views

Show all tags related to a category?

Is it possible to show all tags that are related to a category? I can't find anything on it. Thanks. Edit: What I am looking for is this: I know a category slug or name. I want to get all tags ...
1
vote
1answer
182 views

Sorting across blocks (to get prev/next links)

issue is an entry that has a matrix field named contents, whose blocks have an entries field named works, and the related works channel has an entries field named authorPeople. Issue 1's contents ...
1
vote
1answer
316 views

Ordering relatedTo entries

There are a few tickets touching on this, but the solutions proposed aren't working and I'd like to share the use case: I have a Table of Contents page that is outputting a set of entries based on an ...
2
votes
1answer
89 views

Relating a Category Entry to a Categories Field Type

I've been trying to get this working but can't seem to find a solution. I have two different types of Categories in a commerce project. Level One Level Two Examples Level One would be Mens, Ladies,...
2
votes
1answer
2k views

Using the Search Filter with Entry Fields

I've got an entry page and at the bottom I would like to show related products and then underneath that, related offers. As the main page entry isn't assigned to any categories I've tried to use a ...
2
votes
1answer
321 views

Loop through entries that share current entry category and restrict to Cat Group Id

I've been racking my brains trying to get my head around categories and entries, hopefully someone can help and show me the best way. I have an entry page with product information and this product is ...
2
votes
1answer
310 views

Querying relational data in plugin

I'm creating a plugin and I need help to query relational data. Here's the table schema I have: collection +----+-------------+---------------------+---------------------+-----+ | id | label | ...
1
vote
2answers
286 views

Empty relation field validation failed with Guest Entries plugin

I am trying to save a entry with the Guest Entries plugin. The entry has a custom field 'office' thats set to 'entry' a relation to section 'offices'. <fieldset class="form-fieldset row-spacing-2"...
1
vote
1answer
338 views

Order by related entries count

I have a channel with a related users field. I want to output all channel entries ordered by the number of related users, this is what i have so far: {% set entries = craft.entries.find({ ...
1
vote
1answer
243 views

Prettiest way to loop through nested relations?

Let’s say i have a location channel, a studio and a team channel. A location contains one or several studios and a studio contains one or several teams. I can display all the teams in a location by ...
1
vote
1answer
228 views

How to add a user to a Users field from front-end form?

Is it possible to update an entry’s Users field from the front-end? If so, how would you go about it? The situation is this: training events are created and then posted for members to bid on for a ...
1
vote
0answers
171 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 ...
0
votes
1answer
55 views

User specific entries (relations)

Does anyone know how I can show a specific entry to a user (frontend)? My user field is called "gebruiker". {# Get current member e.g URL /members/1/ #} {% set currentMember = craft.users.id(craft....
4
votes
1answer
205 views

Get random entries, excluding an array of entry IDs, where a relational field is not empty

I'm trying to pull a set of 3 random entries from a Section. The entries need to have a certain Assets field not empty, and I also have to exclude entries already pulled (these entries are stored in ...
2
votes
2answers
314 views

How to remove relationships between entries

I have a channel called 'Activities' and a channel called 'Members'. In 'Activities' I have a field called 'Accepted'. I want to be able to add and remove 'Members' to the field 'Accepted'. I want to ...
1
vote
0answers
54 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 ...
3
votes
1answer
576 views

How to order by related entry type field

Two sections: 1) Products 2) Authors The "Products" section pulls the author name from the "Authors" section through an entries type field. I'd like to order the products first by authors (...
2
votes
1answer
618 views

Working with multiple categories

Does anyone know if you can work with releatedTo between categories? I’d like to get all the categories in a categories.groups that are related to a single category I have some entries in a channel, ...
1
vote
0answers
81 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 ...
7
votes
1answer
746 views

Eager loading of reverse related elements?

Is it possible to load reverse related elements? I mean if the elements I’m querying are the target elements? Example: I’m setting up a criteria model to get some categories and I also want to load ...
1
vote
1answer
104 views

Displaying image from related CraftCommerce entry

Folks: I'm using CraftCommerce. I have a main product and several accessories related to that product. Accessories have a title, description, price, and image. Now, I have no problem pulling the ...
3
votes
1answer
271 views

Relating entries to assets within an ElementAction

I'm following the Element Actions example from the official Craft docs. I've defined an Artist entry type, and have defined an entries field on my Assets to relate an Artist to each Asset. To avoid ...
0
votes
0answers
61 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 ...
3
votes
1answer
112 views

.relatedTo() not returning tags with spaces

I think I'm seeing a bug while using advanced search with relatedTo(). If I use a simple search, like this: {% set param = { order: 'RAND()', limit: null, search: "#{request.tags}" } %} It ...
4
votes
1answer
354 views

Many db requests with relationship fields

I have a page with a lot of entries fields. They are awesome but that leads also to a LOT of db requests. Aside from caching are there some best practices to lower db requests on entries fields? For ...
1
vote
1answer
165 views

Display a new entry modal when clicking on a relation field

For a complex website we have nested a relation field inside a matrix. It makes little sense for us to show the list of already created entries so we would prefer to directly display the new entry ...
1
vote
1answer
100 views

Show posts related to entry AND all posts not related to any entry

I'm struggling to get my head around relations. It seems overly complex for the simple thing I want to do. I am using an entry field on my post to set relations by city. These entries are limited to ...
0
votes
2answers
190 views

How do you create pagination links related to entries within a Matrix Field in a single entry?

I have combed through similar questions, although my pagination links are not performing properly. I would like to add pagination links to entries within a channel. And I would like for the ...
0
votes
1answer
683 views

How to query for multiple relations with SuperTable

The relevant sections for this question are: Event: One relevant field. guestAllocation (SuperTable). Guest allocation is a table which selects a Partner (Entries) and how many people that partner is ...