Questions tagged [element]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
65 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
52 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
0answers
66 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
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 ...
1
vote
1answer
26 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
21 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
133 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
27 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
421 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
188 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
1answer
225 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
96 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
307 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
186 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 ...
2
votes
2answers
670 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( ...
1
vote
1answer
671 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
271 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
93 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
454 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 ...
2
votes
2answers
375 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);, ...