Questions tagged [elementcriteriamodel]

Questions having to do with Craft's ElementCriteriaModel, which is used to return a set of elements narrowed by a variety of parameters.

16 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
268 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 ...
3
votes
0answers
202 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 ...
2
votes
0answers
75 views

Unable to get relatedTo working on an ElementCriteriaModel

In a plugin I am trying to get Users related to other Users: $criteria = craft()->elements->getCriteria(ElementType::User); $criteria->group = 'partners'; $criteria->relatedTo = [ '...
1
vote
0answers
26 views

Retrieving Entries by Category & Exclude by Tag

I have an endpoint that I want to retrieve entries by a category, but then exclude entry ids if they have a certain tag. It seems to me that the relatedTo param overrides the id param that says not in ...
1
vote
0answers
17 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
0answers
23 views

Get Entries with a specified. Custom FieldType

I have created a Custom FieldType with AttributeType::Mixed The field actually saves the a Custom Model I created. I'm trying to retrieve all the entries that have my custom model as the field. I'm ...
1
vote
0answers
316 views

Element API plugin: searching and working with nested objects

I’m experimenting with the Element API plugin and working with querying the tags of the assets that appear in matrix blocks in a set of entries. Essentially I’m hoping to be able to use a tag in a ...
1
vote
0answers
97 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
45 views

Save or efficiently query a count from a related table

I have two custom element types, Event and Booking. They are related via the eventId column on the Booking record which is a FK to the Event record. The Booking record also has a seats column. A ...
1
vote
0answers
161 views

Craft 3 improvements to relationship querying?

I've been using Craft for a couple of years now and I do love it, however I consistently run into massive performance issues with it. I heavily rely on caching and eager loading - however this doesn't ...
1
vote
0answers
44 views

Find category through ajax using ElementCriteriaModel

I'm trying to run a controller action with ajax in a new plugin I'm making. The action needs to return all categories from a group, so nothing impossible here. When I run the actionUrl in the ...
1
vote
0answers
50 views

When constructing an ECM, is it possible to compare two values?

My section has two numeric fields, lorem and ipsum. It's possible for users to enter any integer they want into these two fields. I want to grab all results where lorem is greater than ipsum. Here's ...
1
vote
0answers
100 views

How do you check for a value in an array with the criteria model?

I am building plugin which has a function to return any users that have a specific interest checked in their profile. The interests field is an array. What I need to do is check if the specific ...
1
vote
0answers
120 views

FieldElement Solr

for the last few hours im trying to come up with a way to use the craft field select in combination with SOLR, all my entries are in solr and i i want to keep using that. ive made it so that solr can ...
0
votes
0answers
22 views

Setting a variable to a Matrix field with additional parameters

I'm trying to set a variable to a Matrix field and apply additional query parameters like so: {% set monthDates = entry.scanDates.type('dates').date('and', '>= ' ~ currMonthFirst|date('Y-m-d'), '&...
0
votes
0answers
86 views

If an entry doesn't exist in a locale and returns a 404, how can I check if the entry exists in a different locale?

I'm trying to create a mechanism for informing users that a particular entry is not available in the selected language, and providing a link to read the article in an alternative language. Therefore, ...