New answers tagged

0

I fixed this issue by going to admin/people/permissions and selecting all of the Simple OAuth permissions for Authenticated User. I'm sure a more refined approach to selecting permissions will be possible, but initially selecting all of them has fixed this issue for me.


1

In page.html.twig and Drupal 8.7.6, I had to use: {% if language.id == 'en' %} or {{ language.id == 'en' ? 'active' : 'not-active' }} Other suggestions did not work.


0

Why are you using field's attribute 'name' instead of it's machine name 'field_prenom'? If you check in 'kint' you would get the hierarchy of 'placeholder' attribute. You can update placeholder using form_alter only. Check the below example. $form['field_name']['widget'][0]['value']['#placeholder'] = 'Nom';


0

This works for me: var search_key = $('.path-frontpage .ui-autocomplete-input').val();


0

The best way to work using bootstrap theme is by creating a subtheme. In the subtheme, you can update the variables or overwrite the navbar min-height, but if you really don't want to change any css/scss at all, you can do it using JavaScript (not recommended). Something like: (function ($) { $(document).ready(function () { $('ul.navbar').css('min-...


2

In a custom module, create a file called mymodule.links.menu.yml. Inside this file, add the following: view.abc_links.page_1: #your view route title: 'ABC Link' route_name: view.abc_links.page_1 #your view route description: 'ABC Description' mymodule.admin.structure.settings: title: 'API Link' description: 'ABC Description' route_name: view....


2

You can go to /admin/structure/menu/manage/admin and add this link.


0

Try below code, and you can trim $label as you want. /** * Implements hook_search_api_autocomplete_suggestions_alter(). */ function HOOK_search_api_autocomplete_suggestions_alter(array &$suggestions, array $alter_params) { $used_labels = []; /** @var Drupal\search_api_autocomplete\Suggestion\Suggestion[] $suggestions */ foreach ($suggestions as $...


0

If you take a look at this page, you can see that what comes out of the box, is that you create a seperate product variation for the recurring products and then create seperate products. Instructions from the docs: Download and install the Commerce Recurring Framework and Advanced queue Drupal modules. Create a variation for the recurring ...


0

You can add custom submit handler to your Webform through hook_form_alter for inserting it's data into your custom table. To achieve it check the below example. use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Database\Database; function MODULE_NAME_form_alter(&$form, $form_state, $form_id){ if($form['#form_id'] == "YOUR_WEBFORM"){ $form['...


0

I solved the problem by creating a custom CKEditor plugin. This is the JS code, in case anyone find it helpful: CKEDITOR.plugins.add('tableclass', { beforeInit: function (editor) { editor.ui.addButton('addtableclass', { label: 'Add table class.', command: 'addTableClass', icon: '/modules/custom/mymodule/icons/add.png' }); }, ...


5

The latest releases of Drupal 8 are "supported but not recommended" on Drush 8. Drush 8 is still necessary if you are not using Composer to build your site. Composer is recommended for all Drupal 8 sites because sooner or later you are likely to need a module that requires Composer. If your site does not yet need such a module, though, then it is possible to ...


1

It's not clear what entity type you have. In the question you ask for the label of a content type, which would be the entity node, then the label field is title. In the question title it is a more general question about the label of an entity and in the code you redirect to a group_content entity route, which would suggest this is another entity type. In ...


0

If you are trying to update a node you can use setTitle(), like this: $entity->setTitle('My custom title'); For other entity types you can use: $entity->setLabel('My custom title'); I also see that you don't save the entity, make sure to save the entity after setting the title: $entity->save();


1

[node:title] will give you the node title.


1

My solution for this in the end was to use a method on the webform object called getPagesWithElements. // Get webform object $webform_obj = \Drupal::entityTypeManager()->getStorage('webform')->load('webform_id'); // Get page/element structure $model = $this->getPagesWithElements($webform_obj);


1

It looks like you will have to define a custom process plugin to do this - I can't find any plugin for it on this or this page. There is a PHP function called htmlspecialchars_decode, which decodes all HTML special character entities, which you can probably use. It takes in a string and returns the decoded string. We also need to pass it the ENT_QUOTES flag ...


0

How about using hook_entity_presave? /** * Implements hook_entity_presave(). */ function MY_CUSTOM_MODULE_entity_presave(EntityInterface $entity) { $type = $entity->getEntityTypeId(); if ($type == 'node') { // Add more logic based on your needs. $entity->set('title', 'kkkkk'); } }


1

'Display Selected and Unselected' module - is one of the possible solutions for Drupal 8.


0

Try this: use Drupal\commerce_payment\Entity\Payment; $payments = \Drupal::entityQuery('commerce_payment') ->condition('order_id', $order->id()) ->execute(); foreach ($payments as $value) { $payment = Payment::load($value); $payment->setState('completed')->save(); }


0

You probably want to write this as an update hook, something like this should work: function MY_MODULE_update_N() { foreach (\Drupal::entityTypeManager()->getDefinitions() as $entityType) { $entities = \Drupal::entityTypeManager()->getStorage($entityType)->loadMultiple(); foreach ($entities as $entity) { if ($entity->langcode->...


1

If you use [webform_submission:node:field_sports:0:entity] you can get field values form the taxonomy term. So to get the name, you can use: [webform_submission:node:field_sports:0:entity:name]


2

In your modules *.module file you must implement hook_theme() like this: /** * Implements hook_theme(). */ function fax_theme() { return [ 'fax_custom_theme' => [ 'variables' => [ 'test' => NULL, # Makes the {{ test }} variable available in the template. ], ], ]; } Then you can return this in your block: $test = '...


0

I didn't find a direct answer, but I used the module "Menu Link Attributes" to add a class and used JS to add the parameter: $('#menu ul li a.parameter').each(function() { $(this).attr("href", $(this).attr("href") + "?p=parameter"); }); Maybe that's helpful.


0

It would appear that this needs to be done using a Remote Post handler (which can be added at site.com/admin/structure/webform/manage/form_id/handlers) instead of selecting the custom POST setting, as described at https://www.drupal.org/project/webform/issues/2961835


0

Unfortunately, composer is always going to apply any patches you have defined that are not already applied whenever it runs. You can comment out the patches, run your composer command, and then uncomment them.


0

Many people may tell you this is what NOT to do, but for exotic and incomprehensible reasons, TrustedRedirectResponse can cause your controller to throw the error about metadata leaking "somewhere". I checked all around my desk and on the floor, and I couldn't find any metadata :) This can happen even if you disable caching for your route in every ...


0

Your main concern is you don't want the /node/123 link to be available publicly or in search results? You could unpublish the node and then make a Boolean field in your content type and for your view choose to show the piece of content based on your new boolean field INSTEAD Of the stock published/unpublished checkbox. So your view by default will only ...


2

I solved the problem by adding a media image field on the remote video media entity and then altering the media entity on presave, like this: /** * Implements hook_entity_presave(). */ function MY_MODULE_entity_presave(Drupal\Core\Entity\EntityInterface $entity) { if ($entity->getEntityTypeId() == 'media' && isset($entity->custom_thumbnail-...


1

Go to /admin/appearance, uncheck the box name 'Use the administration theme when editing or creating content', and save.


0

Because you do not want to alter some data, you should use a preprocess function for this. Check this out: function MYMODULE_preprocess_views_view_unformatted(&$variables) { $view = $variables["view"]; $viewId = $view->id(); if($viewId == 'my_view_id'){ $rows = $variables['rows']; foreach ($rows as $id => $row) { $important = $...


1

To attach a library to a certain paragraph type you could use template_preprocess_paragraph__PARAGRAPH_TYPE() like following. Note how it's just added to the $variables array not the element. function MYTHEME_preprocess_paragraph__slider(&$variables) { $variables['#attached']['library'][] = 'MYTHEME/carousel-styling'; } Same with the field. Simply ...


0

$ drush entity:delete node --bundle=article --exclude=9,14,81 or $ drush entity:delete CUSTOM_TYPE --exclude=1,2,3 I added the --exclude option as a pull request #4175 to Drush. It also works in Drush 9, so you could use this pull request to patch your local Drush like that: "patches": { "drush/drush": { "Add option to exclude entities by ID ...


0

Interesting question and a typical use case. In a custom module, do the following: use Drupal\views\ViewExecutable; function helper_views_pre_render(ViewExecutable $view){ if ($view->id() == "numbers" && $view->current_display == 'page_1') { $total = 0; foreach ($view->result as $value) { $number = $value->_entity->...


0

If it is a custom variable, you should use $form_state->set('property_name', 'value') (instead of "$form_state->setValue(...)"). Example: public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); // Update custom variable (in PHP "null + 1" equals one) $form_state->set('...


2

The imagecreate function is part of php's gd library. If a server has been set up manually it's possible it doesn't have the gd library. First, figure out which version of php you are using, for example with this command: dpkg -l | grep '^ii' | grep php Look for a line like: ii php7.2 7.2.19-0ubuntu0.18.04.2 all server-side, HTML-...


2

The entities aren't loaded by default (for performance reasons), but TermStorage::loadTree takes a $load_entities parameter: If TRUE, a full entity load will occur on the term objects. Otherwise they are partial objects queried directly from the {taxonomy_term_data} table to save execution time and memory consumption when listing large numbers of terms. ...


1

There are more ways of solving it depending on your circumstances. The obvious way is through 2 views displays with different paths, or as parent-child path3 for the first one and path3/path9 for the second one (you can set them as Drupal tabs that way, so Drupal tab can play the role of your button "Show 6 more"). Set one to only show 3 items, the other ...


0

How to get it form media entity {{ media_entity.field_media_image.title }} {{ media_entity.field_media_image.alt }} How to get it from node {{ node.field_yourimagefield.entity.field_media_image.title }} {{ node.field_yourimagefield.entity.field_media_image.alt }}


0

You can add an header field in your view.


1

You could try to add your own template suggestion via hook_theme_suggestions_HOOK_alter, which would mean hook_theme_suggestions_container_alter. There you might target the container by id or some other attribute (id does not seem promising here). The container.html.twig does only provide a wrapping div around other content. While you could add more html to ...


0

Don't forget to enable required services under /admin/config/services/rest: Enable REST resource "Webform Submit" Enable REST resource "Webform Elements" Enable REST resource "Webform Submission"


0

You may grant your permissions on install time of your module with a simple config in config/install/user.role.publisher.yml (about this): langcode: en status: true dependencies: { } id: publisher label: Publisher weight: 3 is_admin: null permissions: - 'add contact entity' - 'edit contect entity' Your code above is not a "grant", it's a runtime-check ...


0

There's a default config for flood settings in core/modules/user/config/install/user.flood.yml: uid_only: false ip_limit: 50 ip_window: 3600 user_limit: 5 user_window: 21600 This means, that your user is locked for 21600 secs by default. Be patient :-) Unfortunately, there's no UI for that config currently. A workaround would be to import a single config ...


0

Expanding on @ahebrank's answer, if you have the route name 'my.route.name', but not the route object itself (and taking into account the caveat's mentioned by @ahebrank's) here's how you can do it: $route_provider = \Drupal::service('router.route_provider'); $route = $route_provider->getRouteByName('my.route.name'); $title = $oRoute->...


6

You can fetch the node using routeMatch and add the class like this: function THEME_NAME_preprocess_html(&$variables) { $routeMatch = \Drupal::routeMatch(); $node = $routeMatch->getParameter('node'); if (isset($node) && $routeMatch->getRouteName() == 'entity.node.canonical') { if ($node->isPublished()) { $variables['...


2

You can a create as many block plugins as you want within a single module. Each of these plugins must have a unique ID in annotation. In order to reduce code duplication you can create an abstract class that would hold all common functionality. Other classes can extend it and override methods that need a different implementation.


0

If your question is for showing the day on the content create/edit form, and not displaying after saving that form (which I answered in the previous answer), you'll have to change the widget for the date field. You can do that through some custom code, but I believe the Bootstrap Datepicker module can do that too (I haven't tried it). That module has the ...


1

Got it myself. Configuration is absolutly correct, but i set the wrong reverse_proxy_adresses to be allowed. I thought, that i can use the beanstalk-url, but it worked perfectly fine with one of the internal IP Configs for AWS: 172.16.0.0/12


0

Don't forget to add a block category as well. /** * Provides a block with a simple text. * * @Block( * id = "BLOCK_MACHINE_NAME", * admin_label = @Translation("BLOCK_DISPLAY_TITLE"), * category = @Translation("SUCH_AS_VIEWS_MENU ETC") * ) */


Top 50 recent answers are included