Drupal Planet

Balint Pekker: Simplifying Drupal Documentation

9 hours 32 minutes ago
Are you new to the world of Drupal, eager to dive into its powerful capabilities, but encountering obstacles in the form of outdated tutorials and confusing documentation? You're not alone. Beginning your Drupal journey can feel like navigating uncharted territory, leaving many feeling frustrated before they even begin.

Drupal Core News: Drupal 11.0.0-alpha 1 will be released on the week of April 29, 2024

15 hours 47 minutes ago

Last month, we announced that depending on readiness of the codebase to 11.0.0 beta requirements today on April 26, 2024, Drupal 11 would be released either on the week of July 29, 2024 or the week of December 9, 2024.

The Drupal 11 codebase progressed a lot since then, it is based on Symfony 7 and jQuery 4, and the deprecated APIs have been removed. However, while we are making rapid progress on PHPUnit 10 support, we need to fully complete that update to PHPUnit 10 before a beta release, which will not quite be ready for next week.

To help the community prepare for Drupal 11, we decided to make Drupal 11.0.0-alpha1 available next week (on the week of April 29, 2024), alongside Drupal 10.3.0-beta1. This also means that those attending DrupalCon Portland 2024 the week after can already try out the first tagged version of Drupal 11, and modules can add Drupal 11 compatibility confident that all runtime APIs are stable.

We are giving ourselves an additional couple of weeks to run down the last PHPUnit 10 issues and any other remaining beta blockers ready for a stable Drupal 11.0.0 release on the week of July 29, 2024. Assuming all goes well, we'll make a final decision by May 10th and release a beta shortly afterwards.

LN Webworks: How To Create Custom Token In Drupal: Step By Step Guide

1 day 2 hours ago

In Drupal 10, you can create custom tokens using your custom module. Before creating custom tokens, you need to have the Drupal tokens module installed on your Drupal site. This contributed module already comes with some predefined tokens. These defined tokens can be used globally.

Steps to Create the Drupal Custom Tokens

1. Begin by creating a yourmodule.module file in your custom module directory.

2. Establish your custom token type.

 

The Drop Times: Streamlining Local Development with DDEV, Docker, and NGROK

1 day 4 hours ago
Discover how DDEV, Docker, and NGROK can revolutionize your local development process. Our latest guide dives into the seamless integration of these powerful tools, offering you the most efficient way to set up, develop, and test your Drupal projects right from your local machine. Streamline your workflow and enhance productivity with our comprehensive insights!"

Drupal StackExchange

How to pass Webform elements from controller to custom twig template

23 hours 55 minutes ago

I'm pretty new to Drupal and probably this is simple but I got stuck with this.

What I'm trying to do: I have created a custom module where I have defined a custom route to display my webfrom in custom twig template.

How and what to return from Controller so my webform elements will be available in custom twig template.

my_module.module /** * Implementation of hook_theme * * Since we have a lot to explain, we're going to use Twig to do it. */ function my_module_forms_theme($existing, $type, $theme, $path) { return [ 'my_template' => [ 'variables' => ['test_var' => NULL], 'render element' => 'form' ], ]; }

my_module/src/Controller/MyModuleController.php namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class MyModuleController extends ControllerBase {

public function content() { $my_form = \Drupal\webform\Entity\Webform::load('my_form_id'); $form = \Drupal::entityManager() ->getViewBuilder('webform') ->view($my_form);

$build = [ '#theme' => 'my_template', '#form' => $form, ]; return $build;

} }

In my twig template, I want to be able to use form elements like below. Please let me know how to achive this.

my-template.html.twig {{ form.element.name }} {{ form.element.email }}

Thanks

Alan

import address data from CSV

1 day ago

I migrate my content from an old D7 site to D8 site. All went well, except the addresses from field address where not migrated to the new address field.

Then I use feeds, feeds_migrate, content-import... Nothing work for this.

Then finaly start learning how to do this in a custom module. I used the plugin from the module addres, I wrote my own plugin. No migration seems to work.

I have a CSV file with the addresses. There is also a NID row that is unique, I also try with the title field who also is unique. I try to import this csv file into my content type business. The nodes are existing with the NID numbers. Just try to fill the address in each content. All addresses are in Belgium.
Below my YML file in a custom module.

id: migzaal label: Adres veld migratie source: plugin: csv path: modules/custom/adresmigratie/assets/adresinvoer.csv header_row_count: 1 ids: - Nid process: nid: Nid field_adres: plugin: addressfield destination: plugin: 'entity:node' default_bundle: business overwrite_properties: - 'field_adres/address_line1' - 'field_adres/locality' - 'field_adres/postal_code' - 'field_adres/country'

Can someone guide me in the right direction. Thanks.

Belba

Drupal - add machine-name as css class to my blocks

1 day 1 hour ago

So I would like to give my blocks the internal machine name of the block as a CSS class? I can add the block ID and the block type as presprocess via theme.theme:

function xxx_theme_preprocess_block(&$variables) { // adding custom attribute class for block if ($variables['elements']['#base_plugin_id'] == 'block_content') { $blockType = strtr($variables['content']['#block_content']->bundle(), '_', '-'); $variables['attributes']['class'][] = 'block--type-' . $blockType; } }

but how exactly do I get the machine name of the block? Does anyone have a tip for me? Would I like to stick to programming and not install a module, or can I get the machine name more quickly via the Twigtemplate? Would be very grateful for any help.

Bavra

Bavramor

Filter date from current date to upcoming 7 days?

1 day 1 hour ago

I have a week type calendar view. It currently displays form SUN to SAT of the current week.

But I need to display it starting from current date to current date + 7 days

How can I achieve this?. I am using Calendar Module and created a view using it.

My view is displayed only if I add a contextual filter. With default value as current date. This adds a filter criteria from dates starting from the start of the week and end of the week.

user46121

composer install error

1 day 2 hours ago

I can't install anything because of this error:

[RuntimeException] Could not scan for classes inside "/app/vendor/symfony/serializer/src/" which does not appear to be a file nor a folder

and subsequently:

Could not scan for classes inside "/app/vendor/symfony/yaml/src/" which does not appear to be a file nor a folder

I navigated to that directory and the src folder is indeed missing...

I'm using Lando and switch the PHP to 7.1. I tried deleting the vendor directory and rerunning lando composer update and lando composer install but get the same errors.

AlxVallejo

Warning: Invalid argument supplied for foreach() in form_select_options() (line 2837 of includes/form.inc)

1 day 3 hours ago

I get the following erros on selecting the selectbox. Here onchang of this field will populate another checkbox with city details id zipcode using ajax callback.

$zipcode_options = get_all_zipcodes_ascending(); // Populate Ort on auktion clone. $selected = isset($auktion->zip_code) ? $auktion->zip_code : NULL; $selected = isset($form_state['values']['zip_code']) ? $form_state['values']['zip_code'] : $selected; $ort_options = _ajax_city_dropdown_options($selected); $form['zip_code'] = [ '#type' => 'select', '#title' => t('PLZ'), '#options' => $zipcode_options, '#default_value' => isset($auktion->zip_code) ? $auktion->zip_code : "", '#select2' => ['width' => '100%', 'placeholder' => t('Enter a zipcode'), 'allowClear' => TRUE], '#empty_option' => '', '#validated' => TRUE, '#required' => TRUE, '#ajax' => array( 'event' => 'change', 'callback' => 'ajax_example_dependent_dropdown_callback', 'wrapper' => 'dropdown-second-replace', ), ];

Referenced many links but cannot find a solution to resolve this issue.

References:

https://www.drupal.org/node/586576

populate drop down from results using ajax

http://techqa.info/drupal/question/203725/help-understand/solve-this-warning:-invalid-argument-supplied-for-foreach%28%29-in-views-that-requires-class-registry-clean-to-mend

developer