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
0
votes
1
answer
204
views
How to get a variable from FieldWidget in the same modules Template
I have module that is currently setup like this
module
-signature.module
-signature.info.yml
-src
-Plugin
-Field
-FieldWiget
-SignatureWidget.php
-templates
-...
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/...
1
vote
1
answer
1k
views
How to use ajax in field widget form?
I need to store a country and a region for geographical objects. Countries and regions are stored in a taxonomy vocabulary. Moreover, some countries have regions (as child terms) but someones don't ...
0
votes
1
answer
145
views
Custom field - Object could be converted to string
I have a very simple custom field/widget/formatter set.
YoutubeLink.php (custom field):
<?php
namespace Drupal\ad_general\Plugin\FIeld\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\...
1
vote
1
answer
318
views
Extending an existing Plugin class results in Class not Found PHP Fatal Error
I am trying to create my own Plugin that extends an existing Plugin class.
I can extend the base class and everything is fine.
However, if I extend a existing Plugin class, I get a Class not Found ...
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 ...
1
vote
2
answers
217
views
Custom plugin modified results in WSOD PluginNotFoundException
I've created a module with a custom Plugin ("group_user"). It all worked great until I modified the code and accidentally introduced an error. This resulted in a WSOD Drupal\Component\Plugin\Exception\...
0
votes
0
answers
153
views
Changing a plugin constructor?
There is a plugin being used that extends WidgetBase in Entity Browser module (which extends PluginBase from core).
There is an abstract class that extends WidgetBase, and type hints an argument to a ...
0
votes
0
answers
330
views
Override a method implemented by a third-party module
I want to change something in a method implemented in a third-party module without hacking the module itself, but overriding the method in my module.
The third-party module is views_data_export. I ...
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 ...
1
vote
1
answer
134
views
Get labels from fields ordered on block plugin - Drupal 8
I'm trying to create a block with a label list using all labels of a specific field type, entity_reference_revisions.
I created a Block plugin and load the EntityTypeManager service.
I tried:
$...
1
vote
0
answers
768
views
Custom exposed view filter plugin drupal 8
I am totally new to drupal 8 I have custom view field plugin created to render the user type permission(anonymous or authenticated) for each node displayed in view.
for that i used the content access ...
0
votes
0
answers
28
views
Plugin block not displayed in views page
I have a created views (page) to display the number of news articles created in each month (This displays month (number of articles) added in that month like May(12)).
I created a content page and ...
0
votes
0
answers
784
views
Output rendered entity in twig template of views style plugin
How do I output a rendered entity of a taxonomy term in a views style row plugin template?
I am able to access the field gamma from the entity reference field beta of a row with the following code:
{...
1
vote
1
answer
813
views
Can't pass variable to views style plugin template
How do I pass a variable to a twig template from a preprocess function of a views style plugin in a custom module?
In alpha.module, I have tried:
function alpha_preprocess_views_view(&$variables)...
1
vote
1
answer
681
views
Aggregator with custom RSS field
I have a simple RSS feed I am importing via core Aggregator module in Drupal 8.5. One specific field in the Item can't be accessed by Views, and it's critical for display. I'm relying on hacky ...
1
vote
1
answer
4k
views
Why doesn't skip_on_empty work when migrating from a text field?
I'm trying to migrate Drupal 7 users to Drupal 8. In Drupal 7, there's an additional text field representing the user's group. In Drupal 8, it's a taxonomy vocabulary. So I'm using the following ...
1
vote
2
answers
2k
views
Custom content entity field widget. This value should not be null
I've created a custom content entity in Drupal 8 and all is well in those regards. I have an issue when I go to create a new record for my entity using the entity form. "This value should not be null."...
0
votes
1
answer
1k
views
Searchand Replace text in Drupal Nodes
I client has recently been acquired by a new Group and has requested that I do a search and replace for their name e.g. "Foo Group" and replace this with "New Group". There will be multiple instances ...
0
votes
1
answer
206
views
Temporarily disable all modules for troubleshooting
I have a bizarre error going on in the Drupal admin and I want to disable all modules to test if any of them are causing the problem. I have dozens of enabled and dozens of disabled modules. I can go ...
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(...
0
votes
1
answer
871
views
Access data from previously submitted values in buildForm in FormBase plugin
I have a FormBase plugin for an admin configuration page. My desired behavior is to select a series of checkboxes and when you submit the form based on those values a new set of fields will show. ...
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 ...
1
vote
1
answer
696
views
AJAX 500 using In Place Editor to upload managed_file image
I have a plugin that allows the user to upload an image using managed_file to use as a bg image. While using the In-Place editor, I get a Ajax 500 error when trying to upload. I will post my watchdog ...
0
votes
2
answers
1k
views
Trying to create a block plugin module
I am trying to write a custom block module in Drupal 8 that will allow me to place this block into my pages using the block layout screen.
I'm very new to Drupal, so this is very much a "hello world" ...
1
vote
1
answer
2k
views
Cache rebuild causes an error with missing plugin
On rebuilding the cache, a Drupal 8 website goes down and displays the message "The website encountered an unexpected error. Please try again later." I used drush cr to rebuild the cache, which shows ...
0
votes
0
answers
467
views
How to user custom views filter when ajax is enabled
I created a view. And I created a custom filter in a module via hook_views_pre_render.
In this view I have and exposed filter and ajax in enabled.
When the view page is loaded it works perfectly, ...
0
votes
1
answer
205
views
How do I programmatically add a new search page to the search page list?
I have been able to successfully create a search plugin for a custom module, which allows users to search for my custom entity by name. After creating this file, I have to enable it by visiting /admin/...
0
votes
1
answer
931
views
BaseFieldDefinition setDisplayOptions ... type = 'string_textfield' ... unable to set default placeholder or size?
I'm unable to get a default placeholder and/or size to register against a BaseFieldDefinition. I'm trying something like:
$fields['company_name'] = BaseFieldDefinition::create('string')
->...
0
votes
0
answers
707
views
How to create custom block plugin for webform in Drupal 8
I need to create custom blocks for every new webform. When User will create a webform, module should create a custom webform block.E.G. 'webform-1' becomes 'webform-1-block'. The resulting block must ...
0
votes
1
answer
41
views
Set view plugin submit handler
I'm trying to create my own AreaPlugin. But there's submit handler doesn't work.
Here is a part of my code.
class MyAreaPlugin extends AreaPluginBase {
/**
* {@inheritdoc}
*/
public ...
0
votes
1
answer
224
views
How do I create a ruleset component?
I would like to create a custom ruleset component like the one described in How to automatically generate multiple aliases for one node?
That answer is for Drupal 7, and I am using Drupal 8. When I ...
0
votes
1
answer
401
views
How do I properly install?
In order to install MailChimp in Drupal 8 I followed the instructions for the MailChimp Drupal module.
Instructions for 8.x-1.x
The 8.x-1.x release uses version 3.0 of the MailChimp API and ...
-3
votes
2
answers
226
views
After failing to remove fontyourface I'm left with PluginNotFoundException
I ran into the error described in this issue when uninstalling the google_fonts_api used by @font-your-face: https://www.drupal.org/node/2916712
I tried going through some manual uninstall steps for ...
-2
votes
1
answer
167
views
WebformHandler form submit Compile error cannot declare class
I am trying to create a WebformHandler, when adding the handler to a webform via the Webform GUI the error below is what is being displayed. I have search the build and the namespace is only been used ...
0
votes
1
answer
260
views
Access a 'global: custom text' field in fieldpluginbase render()
I'm trying to get more familiar with FieldPluginBase to create a new custom field for views. As an example I implemented a new field called 'dropdown list' that "wraps" other view-fields the user ...
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 */...
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.
...
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?
1
vote
2
answers
611
views
Why is my $node always null in my custom block (using plugin contexts)?
I am trying to make a block that gets the current node via Plugin Contexts.
But my $node is always null. Can anyone tell me why?
I am placing the block with the context module if that makes a ...
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 ...
0
votes
1
answer
79
views
Inventory or Quantity field
TL;TR: Like there is no module like this for D8, how can I create a plugin wich has two fields: one to reference content and onther one to store a number, so I can emulate an inventory.
Hi, I'm using ...
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 ...
0
votes
1
answer
810
views
"Drupal\Component\Plugin\Exception\PluginNotFoundException: The 'integer' plugin does not exist."
When I try to update from drupal 8.27 to 8.35, I get the following error. How can I resolve this issue?
Failed: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "integer" plugin does ...
1
vote
1
answer
164
views
How to rebuild derived plugins after new entities are installed?
I have a problem with a stale plugin-derivatives cache in a kernel test:
protected function setUp() {
parent::setUp();
$this->installConfig(['my_module', 'my_module_test']);
}
The ...
0
votes
1
answer
607
views
Get rendered content of one block created as derivative block
I have created derivative blocks using a method such as this and want to get the contents of a specific derivative block.
I can see all the available blocks (even derivative blocks) that have been ...
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 ...
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' ...
0
votes
1
answer
858
views
Instantiate and load a block programmatically in twig template
I created a simple block that shows some text grabbed from an external source, and it renders as expected when I place it from the back-end (Structure->Block Layout).
But I want to be able to place ...
0
votes
1
answer
560
views
CKEditor scayt Plugin module
I'm trying to build a scayt module to be able to use the CKEditor scayt Plugin. I tried to use this module but it did not work for me. https://github.com/nikhildodeja/scayt I created my own but I get ...