Questions tagged [plugins]
Use it for Drupal 8 plugins; for plugins implemented from the Views module use views, ctools for Chaos tool suite plugins.
214
questions
8
votes
1
answer
3k
views
How set a time type field programmatically?
I create a custom content entity type.
I want one field for the event time.
Since there is no time field, but a dataTime_type, I create a plugin for a custom field :
FieldType : TimeItem.php
/**
...
7
votes
2
answers
422
views
What's the difference between using $this->t('text') and t('text') in a block plugin
I've noticed in many tutorials for constructing block plugins,
$this->t('text')
is used to create translatable text, especially in the block form function. However using
t('text')
doesn't ...
7
votes
2
answers
8k
views
Need to override single Drupal 8 plugin function
What I want to do is edit what is displayed in the autocomplete/drop selects for an entity reference. Basically instead of just [title] I want to show [title] - [other_distinguishing_field]. I know ...
6
votes
1
answer
3k
views
Loading a particular plugin definition by ID
I want to load a plugin definition by its string id within a controller extending ControllerBase. What is the relevant service or class I am looking for?
6
votes
1
answer
2k
views
How do I replace a plugin?
Let's say that I want to replace the block_content_type plugin of the core block_content module to ad some features while not having to rewrite a whole module to achieve this.
It is very easy to ...
6
votes
1
answer
7k
views
Twig Template for a Custom Block Plugin
I'd like to have a custom twig template for custom block plugins from my custom module.
My custom block HeaderText contains
public function build() {
return array(
'#title' => 'Test',
...
6
votes
1
answer
2k
views
Plugin versus Module
Drupal has many specific terms that can have different meanings depending on usage (e.g. view vs. a Drupal View). It looks like another in Drupal 8 is plugin & module. Generically, both seem to ...
5
votes
2
answers
366
views
How can I let a plugin depend on another module?
Is it possible to let a plugin depend on a module (other than the declaring one)?
Use case: I want to create a field widget plugin that should depend on the 'date_all_day' contrib module, but I don't ...
5
votes
4
answers
2k
views
How do I get the current node from a Block module?
I'm looking to create a block that renders differently, depending on the content (metadata, really) of the node in which it is embedded.
The “Title” block is a good example of what I'm trying to do, ...
5
votes
1
answer
6k
views
How to create my own custom simple action in D8?
I'm creating a view that is used to review migrated content that was flagged for review during the migration process. I want to provide a bulk action on this view that allows the user to select a ...
5
votes
2
answers
1k
views
Debug plugin discovery
A plugin that I have written is not being discovered.
For eg : https://www.drupal.org/node/2847639
Is there a general suggestion for debugging failing plugin discovery?
5
votes
1
answer
777
views
Block Plugin Derivatives Discovery
I need some help with my code. I am creating blocks dynamically using the plugin derivatives. I store some form data in a database table, then I display it in each block separately, depending on it's ...
5
votes
1
answer
5k
views
How do I add extra/custom plugins in CKEditor?
I am copying the templates plugin http://ckeditor.com/addon/templates
I put it in my D8 folder /core/asstes/vendor/ckeditor/plugins
I do a 'drush cr'
I do not see the templates plugin under ...
4
votes
2
answers
2k
views
How to override existing plugin?
Considering Drupal\search_api\Plugin\views\query\SearchApiQuery class, I want to override shouldAbort() method there.
I have tried to create a new plugin class in my custom mod:
namespace Drupal\...
4
votes
1
answer
3k
views
How do I inject a dependency into a @FieldType plugin?
I am implementing custom fields in Drupal 8 (types, widgets, formatters).
@FieldType plugins are instantiated by their respective plugin manager (\Drupal\Core\Field\FieldTypePluginManager) which does ...
4
votes
3
answers
7k
views
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "<whatever>" plugin does not exist [closed]
After updading a Drupal site from 8.6.16 to 8.7.1 (PostgreSQL 9.6.13 , Nginx) I get this error in almost every operation (creating a view , installing a module, creating a content type, creating a ...
4
votes
0
answers
2k
views
Difference between service and plugin?
After have read some link i'm still confused about the difference between service and plugin.
I am not speaking about plugin like block or Field formater etc...
i would like to take an example :
I ...
3
votes
1
answer
2k
views
Adding fields to entity (menu_link_content) form (menu_link_edit)
I have been diving into Drupal 8, it's plugin system and all the new stuff for some days now. I hope that I understood the basics and now I would like to start out with a new module.
The module ...
3
votes
2
answers
990
views
How to correctly modify Taxonomy Term selection Plugin
I want some slight modifications of Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::getReferenceableEntities(), for example to not use - to indicate term hierarchy. How can that be ...
3
votes
2
answers
2k
views
Restful permission is required
I've created a @RestResource plugin to provide a REST endpoint to get some data, but when I try a GET from Postman it shows this error:
{
"message": "The 'restful get ...
3
votes
1
answer
1k
views
Basefield 'string' shown as select list widget in entity form
I've got a custom entity ('content_sharing') and defined one of the fields as $fields['entity_definition'] = BaseFieldDefinition::create('string').... The create-form I'm showing the user is loaded ...
3
votes
1
answer
57
views
Field modification using PHP
I have a content type which contains field_state. The nodes of this content type store the two letter abbreviation for the state in each node using field_state. OH is Ohio, CA is California and so ...
3
votes
1
answer
701
views
Execute actions (actions module not rules module) programatically
How can an action from the actions module be executed programatically? In D7 there was actions_do() but in D8 actions are plugins or configuration entities according to https://www.drupal.org/node/...
3
votes
1
answer
590
views
Entities and Plugins. What's the relationship?
As a fairly experienced Drupal 7 developer, I'm thrilled by all the new goodies in Drupal 8, but haven't quite figured out the relationship between entities and the new plugin system.
I've followed a ...
3
votes
1
answer
4k
views
How to fix “Cannot read property 'icons' of null” error?
First of all, I'd like to mention this answer is not related, I'm using Drupal 8.6.1.
I'm trying to create a CKEditor plugin with a new button. In the /admin/config/content page I get the error but ...
3
votes
1
answer
95
views
How can I determine which module is associated with a field plugin?
I'd like to implement an entity hook, and act on all fields defined by Computed Field FieldType plugins. So I either need a list of all FieldType plugins provided by the module or need to know which ...
3
votes
1
answer
1k
views
How to get an instance of a plugin
I am attempting to use a pre-configured instance of a plugin. The plugin is of type @CommercePaymentGateway.
I am currently trying to use something like:
/** @var PaymentGatewayManager $manager */...
3
votes
2
answers
3k
views
CKEditor custom plugin to add richcombo select list
I am building a CKEditor plugin for Drupal 8. I've done plugins that show a button in the editor toolbar, but this one should render a select list. The list is not showing up in the configuration page ...
3
votes
1
answer
228
views
How to set the correct RSS row plugin?
I need to add an image to the RSS feed. So I create a new row plugin for the RSS and it extends RssFields row plugin.
/**
* Renders an RSS item based on fields.
*
* @ViewsRow(
* id = "...
3
votes
1
answer
861
views
How do I make an ajax callback in Field Plugin formElement() reload form?
I've created a custom field as a module Plugin and have the following code in the formElement() method of the field's Widget.php. The intention is to populate options in the second select element ...
3
votes
1
answer
845
views
Migrating into custom node type with multi value field
I'm doing a migration into D8, and I'm migrating into a custom video player field with multiple values. Here's the schema for the field as defined in its plugin:
public static function schema(...
2
votes
1
answer
4k
views
How to add an image(field) to a block?
I want to add a block containing an image-(field) to Drupal, so it can be added to the block layout.
I can see the image gets uploaded (because it appears in my file system). But, the block 'forgets' ...
2
votes
2
answers
2k
views
Destination fields not filled from custom migration process plugin
I'm working on a D6 -> D8 migration, and my destination has a custom video upload field (field_video_upload) that contains three pieces of data: video, thumbnail, and poster (field_video_upload_video, ...
2
votes
1
answer
572
views
custom action plugin with ConfigurationForm
I am trying to create a custom action with Configuration Form Field . I am able to create Action and it is being displayed on content page ( /admin/content ) , but I am not able to find the path to ...
2
votes
1
answer
462
views
Cannot get values in 3rd level SubFormState
I have a block that embeds another plugins into itself and this includes configuration form. I can properly handle the form structure but when it comes to validation I am not able to access the values ...
2
votes
1
answer
120
views
Non-Config Menus
I have this requirement where I would need to create a menu every time a user creates a new instance of a custom entity I'm building. One can easily do this with Menu::create() on entity creation, but ...
2
votes
1
answer
1k
views
Adding Constraint to entity referenced Paragraph field
I'm attempting to follow this documentation to add a custom constraint to a field in a Paragraph but I'm having trouble in adding constraint to that field.
Currently I have book content type with ...
2
votes
1
answer
85
views
How to create configurable plugins under a plugin manager?
I have a custom plugin type and annotation. The purpose of it is so people can develop their own clients for an API integration, and tell the system which plugin to use to perform these actions. I am ...
2
votes
1
answer
837
views
How can I implement paging for a custom query plugin which displays data from an external API?
Hi I have a requirement to display the data from external api but should not be imported into any entities. What I did is I have written a custom view query plugin which displays the data from ...
2
votes
1
answer
557
views
How to debug the evaluate() function of a custom Block Condition Plugin
I'm implementing a custom block visibility condition plugin and am unable to figure out my bugs in the conditional logic, because I can't get a dpm, var_dump, or debug call to work inside the evaluate(...
2
votes
2
answers
884
views
Create a custom area plugin
I'm looking to add a plugin for Views to provide some custom functionality in the footer of a view.
First, I created the following in my_module/src/Plugin/views/area/MyPlugin.php:
namespace Drupal\...
2
votes
1
answer
87
views
How do I find the correct plugin?
As an Drupal 7 developer I'm currently trying to get into Drupal 8.
I got a problem finding the right plugin.
For example, I simple want to change the text of a node link "read more" into "read more >...
2
votes
2
answers
2k
views
How to get block instance id in block plugin?
I have block plugin that renders lazy builder placeholder. In my lazy builder I need to get to the block's settings so I wanted to set the block id as lazy builder argument but it turned out the block ...
2
votes
1
answer
979
views
Place custom Block, return Internal Server Error
I create a Block Plugin in a module,
it be showing the available blocks but when I try to place the block, it returns in the browser console the follow error:
AjaxError:
An AJAX HTTP error ...
2
votes
1
answer
302
views
How to embed plugin configuration form elements into another form?
I have a form that lists entities and each of the entities has a checkbox.
The form also contains a list of actions(Action plugin) that can be performed on selected entities as a select list.
I would ...
2
votes
0
answers
38
views
CKEditor 5 - access PHP plugin configuration from JS plugin?
I have provided a CKEditor 5 plugin a PHP configuration class. I am able to set and store configuration for the text editor plugin now, but do not know how to access that configuration value(s) from ...
2
votes
0
answers
254
views
The form argument Drupal\terminal\Form\TerminalCliForm is not a valid form
I've read through other questions regarding the same error message. They all seem to end up being due to typos or the file path. I don't believe that is the case here, but we'll see. I have a working ...
2
votes
0
answers
306
views
migration using csv and yml for multivalued image field
some problem with sub-process plugin. Here are my yml and csv files.
uuid: c0948690-b539-421e-b306-6a49d14afd64
langcode: en
status: true
dependencies: { }
id: migration_multivalues
class: null
...
2
votes
0
answers
188
views
How to describe data for a custom views filter in the my_module.schema.yml file?
I encountered with a problem.
For creating a custom views filter in my own module I should also describe it in the my_module.schema.yml file.
Could you clarify me, how to do it?
For instance, there ...
2
votes
0
answers
2k
views
How to use custom Javascript inside Drupal8 CKEditor
I have a Javascript for tooltips and other things which work fine in front end but I want the same Javascript to run inside CKEditor too so that the user can see what he/she will get in the front end.
...