Questions tagged [element]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
2answers
790 views

Add custom attribute to standard element from plugin

Developing plugin for Craft 3, I want to add extra property to Assets (data being pulled from other table) I am able to pull in the data by extending element query: Event::on( ...
2
votes
2answers
382 views

Using getCriteria with a custom element type

I've setup a custom element type for badges for a system I'm building, but I've run into some trouble trying to query for badges using craft()->elements->getCriteria(ElementType::Badges_Badge);, ...
1
vote
1answer
358 views

What's the difference between a Component and a Model in Craft 3?

I'm trying to familiarize myself with the Craft architecture and I can't understand whether I should be extending craft\base\Component or craft\base\Model for my business logic models. Component seems ...
1
vote
1answer
259 views

API - Update Asset Volume

Im trying to figure out how to move asset(s) to a different volume. Also if I move it will that affect the entries that are using the asset? Here's what im using to target the asset: $resourceImage = ...
1
vote
1answer
316 views

How can I add programmatically a Tag after SAVE_ON event in case of Assets types

We have to update the Asset after the SAVE_ON event, and the Craft::$app->elements->saveElement($asset); Not seems to be working (it is getting timed out). So what is the best pratice to ...
1
vote
1answer
56 views

How can I tell if a variable is an array or an entry/element query?

We have some components that are used to build pages, like normal, and some where we hydrate them with other data, so we are passing in arrays instead of entries. If something is essentially an ...
1
vote
1answer
221 views

Craft 3 plugin - how to update entry with field of Entries type

Using PHP, I want to update a field of Entries type of an existing entry. Fields of type Text and Number will update with the following code: $entry = Entry::find()->id($entryId)->one(); $...
1
vote
1answer
104 views

How to get related entry data using ElementCriteriaModel in a plugin

I am working on a custom plugin which gets some entry data using $criteria = craft()->elements->getCriteria(ElementType::Entry); $criteria->order('postDate asc'); $criteria->dateUpdated = ...
1
vote
1answer
36 views

Users not fully deleting from the database

From the admin, if I delete a user they disappear from the admin list but not from the users database table. Looking through the code I can see UsersService.php has a function deleteUser which calls ...
1
vote
1answer
152 views

Select specific fields from query

I'm trying to get tags out of the underlying craft DB and serve it as a REST endpoint - however, I'm only interested in exposing the tag id and title, so my data should look like this: {id: 1, title:...
1
vote
1answer
40 views

How html title is generated in entry index page in CP

I am trying to find out how HTML title is generated in entry index page in Control Panel. i know it is generated in src/templates/_elements/element.html file by $this->hook('cp.elements.element',...
1
vote
1answer
25 views

Array from matrix fields without quotations

I am trying to create an array bodyBlocks by looping through all of my matrix fields called blockTextContent: $bodyBlocks = []; foreach ($entry->getFieldValue('pageBuilder')->all() as $block){ ...
1
vote
1answer
184 views

Matrix | Craft 3 Element API / Scout Plugin

I am trying to grab the contents a matrix field (Redactor). Here is the section of code I am struggling with: $bodyBlocks = []; foreach ($entry->getFieldValue('pageBuilder')->all() as $block){ ...
1
vote
1answer
29 views

Merge trashed element with existing one

Is there any way to merge trashed elements with an existing element? I'm creating a custom restore action so you can merge a trashed (commerce) Product with an existing one. The mergeElementsByIds ...
1
vote
1answer
110 views

Loop over table field in Element API plugin

How can I output the rows and values of a table field using the element api plugin? Where I have entries I do ... $industries = []; foreach ($entry->industries->all() as $industry) { $...
1
vote
1answer
251 views

Custom element index page (cp) sortable on dateCreated?

I have a plugin with custom elements that can be sorted on a handful of fields in my CP element index page. I can get the DATECREATED displaying correctly that Craft generates automatically but I ...
1
vote
1answer
471 views

Setting unknown property when trying to join table

I've successfully joined a table to the elements table, however I can't can't seem to add a property so I can use it? Getting the error Setting unknown property when trying to join table Entry::find(...
1
vote
1answer
536 views

How to build complex Element Criteria?

How to fetch Elements with a complex DB query? E.g. with some nested AND/OR conditions or just apply two conditions to one field? For example my Elements have a field eventDate. I want to fetch all ...
1
vote
1answer
752 views

Anyway to extend Craft Entry query search in Craft 3

I've had to manually do an SQL call to the get correct results but I was hoping there would be a tidier way of achieving this in Craft 3? $query = ( new Query() ) ->select('craft_content.title, ...
1
vote
1answer
198 views

Eager Loading Image Transforms In Plugin

The craft docs on eager loading show you how to eager load image transforms in twig. {% set entries = craft.entries({ with: [ ['coolImage', { withTransforms: ['transform'] }] ] }) %} ...
1
vote
0answers
84 views

change core element index pages

Is it possible to change core elements index pages -like entry index page- by plugin in PHP way, like extending their twig, using events, hooks and not manipulating DOM with Javascript? Currently ...
0
votes
0answers
44 views

Return message when no users are found in element index page

How can a 'no users are found' message be displayed when the search returns no matching results in index page ?
0
votes
0answers
7 views

Migration: How to show entry attributes after a migration?

I have created a content migration that populates a featuredDate field value within the content table. When editing an entry, this value is populated as expected, however, when viewing the element ...