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
0 answers
295 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
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
84 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 = [ '...
Russ Back's user avatar
  • 1,503
1 vote
0 answers
59 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 ...
Michael's user avatar
  • 33
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,151
1 vote
0 answers
31 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 ...
juanmrad's user avatar
1 vote
0 answers
513 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 ...
Evan's user avatar
  • 11
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
178 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, ...
Alex H's user avatar
  • 945
1 vote
0 answers
107 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 ...
Jamie Pittock's user avatar
1 vote
0 answers
188 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 ...
JamesNZ's user avatar
  • 937
1 vote
0 answers
54 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 ...
Sander Van Keer's user avatar
1 vote
0 answers
60 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 ...
Lindsey D's user avatar
  • 24k
1 vote
0 answers
129 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 ...
Lettie's user avatar
  • 2,033
1 vote
0 answers
155 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 ...
Terraskye's user avatar
0 votes
0 answers
56 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'), '&...
SoHo's user avatar
  • 403