Questions tagged [elementtype]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
15
votes
1answer
3k views

What is getContent() / the ContentModel, and how do I use it to get and set custom field values?

If I want to retrieve content on an element, should I be calling $entry->$fieldHandle or $entry->getContent()->$fieldHandle? What’s the difference? Likewise, if I’m setting new content on an ...
10
votes
1answer
321 views

Best way to implement my own statuses on my custom element type?

I'm working on a plugin with its own element type, I'm trying to add custom statuses to the element type. What is the best way to proceed? I have hasStatuses set to true and getStatuses is where I ...
9
votes
2answers
418 views

How to integrate custom statuses in a workflow style custom element type?

I made a lot of progress on my custom element type from this post and with the help of @selvinortiz: Best way to implement my own statuses on my custom element type? I know have custom statuses that ...
7
votes
1answer
1k views

Is it possible to use the ElementType Modal UI for a custom Field Type Plugin?

So I'm writing a plugin to try and create a relationship between two entry sections that is a two way street (Many to Many). I would love to co-opt the UI and functionality of the ElementType modal ...
7
votes
1answer
1k views

How to make use of Element Types

I am building a plugin in Craft, I want to use the Element Types, the documentation seems so hard to grasp. Can you give an example or a template code?
7
votes
1answer
128 views

In my element type index view, why is the first column always empty?

I am creating a simple Element Type to hold form submissions, but I have hit a wall with this one issue I am having. For some reason I cannot get anything to output in the first column of my element ...
7
votes
2answers
345 views

How do you add support to manage content in multiple languages in a plugin with a custom Element Type?

We have a plugin with custom Element Types that allows a user to create a field layout using custom fields. We understand how to setup a localized site and add translation files. This question is ...
6
votes
1answer
446 views

Display thumbnail using defineTableAttributes for a custom Element Type

Hi, I'm new to Craft and VERY new to plugin development. I'd like to display a thumbnail image in my table list view and thought it would be possible to accomplish using a new Custom Element Type. ...
6
votes
1answer
634 views

Allow anonymous submission on a custom element type?

I have a custom element type that I want to allow anonymous submission from the front-end. I have a solid concept on how the form data is passed but I seem to be missing something. I have the ...
5
votes
1answer
560 views

How can you return elements between two values?

I my be in a bit of a "wood for the trees" situation but how is it possible to return elements based on a custom field being between two supplied values. For example returning users based on a number ...
5
votes
1answer
591 views

Use a custom Element Type without sources?

I want to create a custom plugin (element type) that does not allow custom fields. Therefore, when digging through existing element types, do I really need to have the getSources method? If this is ...
5
votes
1answer
243 views

How to trigger updateElements when hide modal?

Is it possible to refresh an element's list when closing a modal? I have a modal ready with: onHide : function(){ //but all what I tried doesn't work here //1: This will do the trick, but ...
4
votes
2answers
334 views

Where exactly are my element type custom statuses stored and used?

I have custom statuses working on the control panel for my plugin. However, there are a few issues I have with custom statues. Looking through the database, I am unable to figure out exactly where ...
4
votes
1answer
248 views

How do I stop an element from populating?

I have an event listener on elements.onPopulateElement, what I want is make a last minute decision if I want to populate or not. I have certain customfields on an admin CP user (eg company). All ...
4
votes
1answer
160 views

Split-style button for “New” custom element

I've got a plugin with a custom element. It evolved based on the basics laid out in the P&T Events sample plugin. On my element's index page, there's a big button to create a "New Element". When ...
4
votes
2answers
182 views

What would cause an custom element listing to just return everything?

I'm creating a plugin with its own ElementType, i've been using the Events plugin by P&T for reference, so I thought everything was going fine. Now when I go to my elements index, I seem to just ...
4
votes
1answer
166 views

Is it possible for an Element Type to return multiple content tables with the getContentTableForElementsQuery() method?

I'm building a plugin where each Element created has a unique content table associated with it. Each individual Element behaves as needed, however, when I try to create an index page that returns all ...
3
votes
2answers
2k views

How do I return ALL entries that are singles

I'm trying to generate a sitemap and wish to output all the entries that have a section type of 'single' but can't get the the correct syntax. All of the entries need to return 'single' for {entry....
3
votes
1answer
331 views

How do I add a value to a tag field type using the entries service saveEntry method?

I am updating an entry using the entries service, I want to add a tag value into a tag field type (classifiedTags). $entry = craft()->entries->getEntryById(120); $entry->getContent()->...
3
votes
1answer
275 views

ElementType CP section does not display table

I can not for the life of me figure out why my cp page will not generate the elements table. On other elementtype pages in the cp there is an XHR request made to a controller called "getElements" and ...
3
votes
1answer
124 views

Filtering list in CP index page for new ElementType

I've created my first new ElementType based on the Events example. The only thing which doesn't seem to be working is the search bar above the listing in the CP. When I type anything into it I just ...
3
votes
1answer
162 views

Using relatedTo programatically?

I'm trying to extend the ElementCriteriaModel using the guide here: https://blog.tighten.co/craft-cms-building-complex-queries-by-extending-the-elementcriteriamodel However I need to re-implement ...
3
votes
1answer
65 views

Detect currently selected source of custom elements

I have a split-style + New Element button for my custom element type. Thanks to this previous thread, the right-side dropdown menu is working perfectly! My question now is, how do I get the + New ...
3
votes
1answer
325 views

Plugin: Linking elementSelectField to own plugin models

I'd like to have an elementSelectField in my plugin. The goal is to select a Company which is defined by my plugin Model. So when clicked, it'll display a list of companies in the Dialog box and you ...
3
votes
1answer
14 views

How to handle soft delete behavior for a custom Element with custom content tables

I have a custom Element (a Form Element) that adds a custom content table for each Element that gets created (similar to how the Matrix Field creates a custom content table for each field). Users can ...
3
votes
1answer
130 views

What's the correct way to relate element types to a custom element type?

I'm working on a custom stock management plugin for a client's Craft Commerce site, and I need to have relations from my custom element type (used to keep a detailed log of stock changes) to the ...
3
votes
1answer
345 views

Eager loading relations in Plugins Element Type

I am creating an ecommerce plugin in Craft, and trying to take advantage of the ElementType. My goal is to list the orders, and also the items ordered in a single column. Is it possible to eager load ...
3
votes
1answer
402 views

Front End Asset Upload to Custom Element Type not working

I have a custom Element Type to which I can add several custom fields. I can create a front end form with most of those custom fields and the submitted data saves just fine. However, I'm getting ...
3
votes
0answers
203 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 ...
3
votes
0answers
276 views

Trouble saving custom fields onto custom element type

Im working on a plugin with a custom element type and i have most things working but i haven't been able to get custom fields to save with my elements using setContentFromPost. I have the record and ...
2
votes
2answers
801 views

Is it possible to use the field layout designer in settings screen?

I working on a simple inquiries plugin and i want it to use custom element types to manage the inquiries. I have the basics working but I'm trying to setup the option to add/edit custom fields on the ...
2
votes
1answer
365 views

Why does a Element Criteria Model Query with Strings on a custom element type not filtering?

having issues doing the classic element type query, works fine with numerical criteria (id, price etc.) but fails on strings, (code, name etc.). It just returns all elements. $criteria = craft()->...
2
votes
1answer
187 views

How would I trigger updateElements for BaseElementIndex from a plugin's JavaScript?

If I wanted to update the Elements listing based on an action taken from a plugin, would it be possible to do this? Setup: We're on an Elements listing page. We filter the results with a search ...
2
votes
1answer
140 views

How would I setup my plugin to use a unique fieldlayout that is unique to the top level of the plugin?

For example: Users. You can only have one fieldlayout per ElementType user which you customize in the settings section. I've got as far as abstracting out the fieldlayout to it's own view, but when I ...
2
votes
1answer
154 views

Change title url of elementtype in the list

I have a plugin. In this plugin I did elementtype which extends the user one, but with only one source "clients". I have and New Client button which points to my plugin Plugin_ClientController which ...
2
votes
1answer
184 views

Why does my custom element type error around locale being missing on the element types' model?

I have made numerous elementTypes in my plugin that all work perfectly but for some reason one elementType keeps having an error when trying to view the Model's content or custom fields. This is the ...
2
votes
1answer
231 views

How to duplicate an element type model with content?

Duplicating models is easy if you do it from the edit view, where you can just omit the ID and pass it along to save(). But how would I go about doing that programmatically without having a POST ...
2
votes
3answers
165 views

Automatic cache clearing when reordering custom element type

I've developed a custom menus plugin which has been working great https://github.com/familiar-studio/craft-menus Im trying to get it work with the build in template caching and realizing the reorder ...
2
votes
1answer
1k views

Using the required field validation in custom element types/plugins?

I am finishing up the last few details on my custom element type. I have custom statuses and public submissions working. The last detail is providing validation on custom fields set through the field ...
2
votes
1answer
27 views

Is it possible to include a thumbnail in an element type index view?

I'm trying to emulate what Assets does, in which a thumbnail of the asset is shown along side the title of the asset. When I alter the _toString() method of the model, what I get is the URL instead of ...
2
votes
1answer
119 views

How to extend Craft.BaseElementIndex for a custom Element Type

I have a custom Element and need to modify the Element Index page. I'm attempting to extend Craft.BaseElementIndex and register the extended class on my Element Index Page. I'm working on a plugin for ...
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);, ...
2
votes
1answer
108 views

How to disable element editor on custom element type?

I'm working on custom element type and I'd like to disable the editor modal at element index view that appears when you double-click on status icons/thumbnails in the title column. Any help?
2
votes
1answer
79 views

How do I setup my Element Types Sources for deep linking?

In the Entries tab in the Control Panel, I see a list of Sources on the left hand side: All Entries Singles News When I click on each of these sources the page filters the appropriate results in the ...
2
votes
1answer
144 views

Does defineSearchableAttributes() work with getter methods on the model?

If I define searchable fields via IElementType::defineSearchableAttributes(), the provided fields have to be model attributes. Can they also be getter-methods on the model class, which may return ...
2
votes
1answer
149 views

Localize custom element types

I explored the events plugin (from https://github.com/pixelandtonic/Events) and I understand the most of that. Now I will try to make the events localized. The Event itself has no localized field, ...
2
votes
0answers
33 views

Using multiple elementTypes in Element API

I am currently trying to create an autocomplete search with the element-api. I need results from two different elementTypes: Product::class Entry::class How do I get results out of both elementTypes ...
1
vote
2answers
269 views

Change custom element Index title via getTableAttributeHtml?

I want to change the title in the index of an custom element. public function getTableAttributeHtml(BaseElementModel $element, $attribute) { switch ($attribute) { case 'title' : ...
1
vote
3answers
455 views

How to check an elements elementType

In Craft 3, I've got a service function that I'm passing either an 'entry' or 'category' element into. I'd like to know how to differentiate between the possible element types; This kinda of works: ...
1
vote
1answer
52 views

How to support chained Element queries with Twig tags

The craft variable allows you to chain queries for your Elements. For example, you can query the first Entry in a section with either of the following syntaxes: {% set entry = craft.entries({ section:...