Custom ElementCondition in plugin #15563
-
In my Exporter plugin, I'd like to use the concept of ElementConditions to give users more control over which elements they want to export. In the first step, I have them choose the Element type, the section/group/etc and the site. Based on that I'm trying to create an ElementCondition, but can't seem to get the correct fields to show up for the correct query. For example, I have 2 category groups. Here's how I'l creating the condition: $condition = $this->elementType::createCondition();
$condition->queryParams = ['section', 'sectionId', 'site', 'entryType'];
$name = ElementHelper::generateSlug($this->name) . '-' . $this->id;
$condition->name = "condition-{$name}";
$condition->elementType = $this->elementType;
$condition->modifyQuery($this->getElementQuery()); However, conditions for both groups contain the same fields, each with the option to set a condition for a field that isn't present on the element in question. To debug I checked which elements were returned from my Am I missing anything as to how this works? Appreciate any feedback you might have :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can set the |
Beta Was this translation helpful? Give feedback.
You can set the
sourceKey
property on the condition (e.g.group:<uid>
) or if you want it to include the custom fields from multiple field layouts, you can pass the field layouts to the condition via$condition->setFieldLayouts()
.