Nonprofit Drupal posts: March Drupal for Nonprofits Chat
Join us on Thursday, March 16 at 1pm ET / 10am PT, for our regularly scheduled call to chat about all things Drupal and nonprofits. (Convert to your local time zone.)
No pre-defined topics on the agenda this month, so join us for an informal chat about anything at the intersection of Drupal and nonprofits. Got something specific on your mind? Feel free to share ahead of time in our collaborative Google doc: https://nten.org/drupal/notes!
All nonprofit Drupal devs and users, regardless of experience level, are always welcome on this call.
This free call is sponsored by NTEN.org and open to everyone.
-
Join the call: https://us02web.zoom.us/j/81817469653
-
Meeting ID: 818 1746 9653
Passcode: 551681 -
One tap mobile:
+16699006833,,81817469653# US (San Jose)
+13462487799,,81817469653# US (Houston) -
Dial by your location:
+1 669 900 6833 US (San Jose)
+1 346 248 7799 US (Houston)
+1 253 215 8782 US (Tacoma)
+1 929 205 6099 US (New York)
+1 301 715 8592 US (Washington DC)
+1 312 626 6799 US (Chicago) -
Find your local number: https://us02web.zoom.us/u/kpV1o65N
-
- Follow along on Google Docs: https://nten.org/drupal/notes
Community Working Group posts: Call for creators for crafting future Aaron Winborn Awards
The Drupal Community Working Group started the Aaron Winborn Awards in 2015 with the support of the Drupal Association, in honor of long-time Drupal contributor Aaron Winborn (see his Community Spotlight), who lost his battle with Amyotrophic lateral sclerosis (ALS (also referred to as Lou Gehrig's Disease in the US and Motor Neuron Disease in the UK) in early 2015.
A few years ago, during our preparations for the 2018 Aaron Winborn Award, we had the idea that the award would be created by a community member. Rachel Lawson, a former member of the Drupal Community Working Group's conflict resolution team, created hand-blown glass awards for both the 2018 and 2019 winners, Kevin Thull and Leslie Glynn.
In 2020 and 2021, Bo Shipley hand-crafted the award from leather for Baddý Breidert and AmyJune Hineline.
Last year in 2022, the award was crafted for Angie Byron by Caroline Achee and her husband, Louis Achee. Both Caroline and Louis are woodworkers, and often donate their time and skills to community-focused organizations in their local area.
We are looking for community members to volunteer their time and show off their skills for the 2023 Aaron Winborn Award.
We would like to have a design idea or commitment by March 31st (or sooner).
The deadline for this year’s award to be ready by May 22, 2023.
If you are interested in crafting this year’s award (or any following year), please reach out to the Drupal Community Working Group.
Community Working Group posts: Nominations are now open for the 2023 Aaron Winborn Award
The Drupal Community Working Group is pleased to announce that nominations for the 2023 Aaron Winborn Award are now open.
This annual award recognizes an individual who demonstrates personal integrity, kindness, and above-and-beyond commitment to the Drupal community. It includes a scholarship and travel stipend for the winner to attend DrupalCon North America and recognition in a plenary session at the event.
Nominations are open to all Drupal community members*, including but not limited to people who have made a big impact in their local or regional community. If you know of someone who has made a big difference to any number of people in our community, we want to hear about it.
This award was created in honor of long-time Drupal contributor Aaron Winborn, whose battle with Amyotrophic lateral sclerosis, or ALS (also referred to as Lou Gehrig's Disease) came to an end on March 24, 2015. Based on a suggestion by Hans Riemenschneider, the Community Working Group, with the support of the Drupal Association, launched the Aaron Winborn Award.
Nominations are open until Friday, March 25, 2022. A committee consisting of the Community Working Group members (Conflict Resolution Team) as well as past award winners will select a winner from the nominations.
* Current members of the CWG Conflict Resolution Team and previous winners are not eligible for winning the award.
Previous winners of the award are:
2015: Cathy Theys https://www.drupal.org/u/yesct
2016: Gábor Hojtsy https://www.drupal.org/u/gábor-hojtsy
2017: Nikki Stevens https://www.drupal.org/u/drnikki
2018: Kevin Thull https://www.drupal.org/u/kthull
2019: Leslie Glynn https://www.drupal.org/u/leslieg
2020: Baddý Breidert https://www.drupal.org/u/baddysonja
2021: AmyJune Hineline https://www.drupal.org/u/volkswagenchick
2022: Angie Byron https://www.drupal.org/u/webchick
Now is your chance to show, support and recognize an amazing community member!
If you know someone amazing who should benefit from this award please submit a nomination.
Also, if you are a creator and would like to help craft one of our future Aaron Winborn Awards, please reach out to the Drupal Community Working group.
Matt Glaman: PHPStan's new @not-deprecated annotation
The PHPStan 1.10.3 release shipped with a new @not-deprecated annotation! This is a great utility, and I am very thankful to stof for contributing this to PHPStan. This annotation fixes an issue I reported in June 2022 during our massive Drupal 10 readiness initiative.
Drupal core deprecated assertion methods in PHPUnit test classes. A handful of modules decided to replace the method under the same name. PHPStan would find the method, detect the original method was deprecated, and report errors on that method's usage. There was no way to say: "Wait, trust me, this isn't deprecated. I know what I'm doing!" The only approach was to use an inline comment or add the error message to the ignored error setting.
If you scan the Address module, you'll get an error like the following:
The Drop Times: Just Keep Showing Up, and the Job Is Yours: Chris Wells | DrupalCamp NJ
Specbee: Mastering Drupal 9 Layout Builder: A Comprehensive Guide to Effortlessly Customize Your Website's Design
When it comes to page building, site builders, content authors, and content editors are constantly on the lookout for a smooth, user-friendly experience. When they wish to design and construct pages, they expect to use drag-and-drop and CKEditor technologies. This identical experience is provided by Drupal Layout Builder's simple page construction functionality in the Drupal core.
The distinctive Drupal Layout Builder offers a potent visual design tool to let content authors alter how content is presented. Layout Builder, which was added to Drupal core in its most recent version, Drupal 9 enables you to add/remove sections to show the content using various layouts and customize your pages according to what you need. With Drupal 9's Layout Builder Module, you can mix these sections to make a completely unique page.
There are two different ways to use the Drupal 9 Layout Builder: Layout Defaults (to design a layout for all the content of the content type) and Layout Overrides (to design a layout for the specific content item). You may learn more about and get started using the Drupal 9 Layout Builder module with the help of this blog.
Watch out for our next article on this series where we dive into using the layout builder and Ctools module to apply view mode patterns!
Introducing the Layout BuilderYou can change how entities like content types, taxonomies, users, and more look by using the Drupal 9 Layout Builder module. Site builders may easily drag and drop blocks, fields, and other elements into place using this feature.
By providing a preview of the changes made as you design your layouts, the layout builder module in Drupal 9 facilitates the layout-building process. The layout builder in Drupal 9 enables previews of the changes made for a smooth layout creation experience rather than requiring users to save every tiny modification they make to the layout and then look it up on the front end.
The layout builder has two modules:
Layout Discovery - Gives modules or themes a means to register layouts.
Layout Builder - Enables users to directly add and organize blocks and content fields on the content.
When designing a layout, Layout Builder uses two key ideas:
Sections - Columns or containers where blocks can be placed. For example, it could be a 2-column layout or a 3-column layout, etc.
Blocks - Content elements that can be placed in sections.
Layout Builder module installation and configurationGo to Extend and activate the Layout Builder and Layout Discovery modules to install and configure the Drupal 9 layout builder module.
Modify the Content Type and TaxonomyOnce the module has been installed, go to Structure, Content types, and select "Manage display" for any content type. For this example, we'll use the "article" content type.
Click the Layout options drop-down menu at the bottom to select "Use Layout Builder," then click Save.
Field formatters are replaced with a "Manage layout" option after Layout Builder is activated in the view mode. Each of the available view modes can be used with Layout Builder.
You will be taken to the article content type layout when you click "Manage layout."
Insert Sections into the LayoutRemove the default section before adding any more ones to the layout builder. Select the "close" button (as depicted in the below screenshot). Also, a button to remove the default section will be available to you on the right side of your screen. Then select "Remove."
By selecting the "Add Section" option, let's add a few sections to our layout. On the right side of the screen, options will also be offered to you so that you can select a layout for your section. For now, let's pick the "Two Column Section."
You will be given the option to select the "Two Column Layout” width. For now, let's choose a "67%/33%". Next, select "Add section."
After being added, each section region should display an "Add Block" link.
Insert Blocks into the Section RegionsYou can add blocks to your area after selecting it for the layout. Simply click "Add Block" and the "Choose a block" option will slide out from the right when you want to add a block.
Selecting a blockJust clicking on the blocks in the right column will choose them. Using the "Filter by block name" text field, you can even locate blocks by filtering out the search based on their names.
For now, we'll choose the "Body" content field.
The field formatter will allow you to make changes when you click on the block you want to add. Click "Add Block" after configuring the formatter.
On the left side of the block, there will be a "Body" content area.
The "Body" field has been added; now save your changes. By selecting "Save Layout" from the menu at the top of the Drupal 9 layout page, you can save all the changes you've made to your section.
To further personalize our layout builder, let's try adding a few more fields to our design.
When you visit a page with article content type after saving this layout, you will be able to see a preview of the layout you just created.
Layout Overrides:The layout we just created will work for all of the articles. Drupal has a number of settings that must be enabled in order to create a custom layout for a certain article. To do this, select "Allow each content item to have its layout customized".
If you visit an article after activating this option, a Layout tab button will be visible.
With the same interface, the layout may now be changed. This, however, will only alter the design of this one piece of content.
Now let's add a block to this page. Create a new one-column section and click the "Add Block" button. Consider the case when we wish to show recently edited content from other users on this page, Filter off the "Recent content" block when adding a new block, then customize it to your needs before saving the layout.
Eventually, when we've included the most recent article block, our page will appear like this.
Important: If you've changed the layout of a single entity, you won't be able to disable the Layout Builder.
You can only update the layout options once you've reset all altered layouts to their original settings.
Layout Builder from CodeWhen it comes to GUI management, Drupal Layout Builder is undoubtedly amazing. The programming problems you deal with while using the tool on a regular basis, nevertheless, might be a little more difficult. Now, you might ask how to use Layout Builder using code.
It turns out that it's rather simple to enable and disable templates for a single entity.
Simply load the display using the following code:
$entityViewDisplay = \Drupal::entityTypeManager- >getStorage('entity_view_display')- >load('ENTITY_TYPE.ENTITY_BUNDLE.VIEW_MODE');It will then return an object of the type LayoutBuilderEntityViewDisplay, which you must then change as follows:
$entityViewDisplay->enableLayoutBuilder();If you wish to additionally set the flag or activate the Layout Builder for a specific view mode:
$entityViewDisplay->setOverridable(TRUE);to enable the creation of unique layouts for a single entity.
After that, you must save everything.
$entityViewDisplay->save();What actually occurs in the background is that the Layout Builder module adds the layout_builder_key to the third_party_settings of a certain entity type, with values for the parameters described above (enabled, allow custom), and then stores the default layout for this type of entity under sections.
A new entity field named layout_builder__layout is created and used to hold the updated layout for this specific entity if the setOverridable option is set to TRUE.
Contrarily, it takes a little more work to create a section using code and populate it with relevant content.
Starting off, let's add a new section. The layout_id parameter, which serves as a layout identifier, must be included when creating a new instance of the \Drupal\layout_builder\Section class in order to accomplish this.
Protip: The layout discovery module contains the default templates. Layouts are defined in *.layouts.yml files. For more detailed information, please check out the following article on how to create custom layouts in drupal.
Then, adding a new element directly to the section would be the simplest course of action. To do this, use the appendComponent method, which accepts an instance of the \Drupal\layout_builder\SectionComponent class as an argument. Nevertheless, before you can develop such a section component, you must first arrange a few things. To start, you will require:
- the uuid of the embedded element,
- the name of the region in the section,
- plugin configuration.
In this tutorial, we'll embed a sample node in a single-column section using the plugin supplied by Entity Blocks:
$section = new Section('layout_onecol'); $uuid = $node->uuid(); $region = 'content'; $pluginConfiguration = [ 'id' => 'entity_block:node', 'provider' => 'entity_block', 'label_display' => FALSE, 'view_mode' => 'default', 'entity' => $node->id(), ]; $component = new SectionComponent($uuid, $region, $pluginConfiguration); $section->appendComponent($component);Always keep in mind that layouts are saved in third-party settings or a field; therefore, in order to save the section, you must do so in one of these locations.
In our case, a field is being used, so:
$entity->layout_builder__layout->setValue($section); $entity->save();You have now added a single column section to an entity and shown an example node in it by following all of these steps.
You may also be interested in Improving Drupal's Layout Builder Experience.
Layout Builder Pros and ConsWe've compiled a brief list of some advantages and disadvantages of Layout Builder below:
Pros:- Deployment is simple because there is no need to add new entity types because the module is already included in the core.
- User-friendly UI with drag-and-drop capabilities.
- Choices for individual entity customization.
- A simple method for combining fields with other entities without the need to add more reference fields.
- A simple method of leveraging entity blocks to embed existing entities.
- New entity types and embeddable elements add to the website's size, which significantly lengthens the time it takes for all items to load.
- The module is UI-focused, so creating new layouts might be simpler. Right now, we have to write code to generate.yml files and templates.
- Dragging elements between sections can be a little challenging when there are many parts in the layout.
- Twig's names are suffixed with uuid, making it challenging to render a specified section and restricting access to sections.
The Drupal Layout Builder opens us to a wide range of intriguing possibilities for managing layouts through both user interface and code. Will it replace all current solutions?
It is the ideal tool, in my opinion, for dealing with the layout issue on a large scale. It seems like the best course of action would be to use widely used modules like Paragraphs and Field Group to create closed components, and then Layout Builder to create pre-made layouts composed of these components.
Layout Builder has a unique purpose, much like every other Drupal module. As a result, it will always perform better in some situations while performing substantially worse in others. Check it out for yourself!
If you’re looking for experts to help you out with anything Drupal, we’re just an email away!
Author: Mustakim Farooqui
Meet Mustakim Farooqui, Drupal Developer, and our own Chess master. He dreams of visiting Europe and enjoys reading novels and tech articles. When not working, you can find him with a game of chess, solving puzzles, or checking out new Linux distros. Give him a strong cup of coffee and he’ll set sail for anything!
Email Address Subscribe Leave this field blank Drupal 9 Drupal Module Drupal 9 Module Web Development Drupal Development Drupal PlanetLeave us a Comment
Recent Blogs Image Mastering Drupal 9 Layout Builder: A Comprehensive Guide to Effortlessly Customize Your Website's Design Image How to Efficiently Fetch Drupal Reference Entities in Custom Modules Image Finding Balance - Santhosh Kumar's Parallel Worlds Want to extract the maximum out of Drupal? TALK TO US Featured Case StudiesUpgrading the web presence of IEEE Information Theory Society, the most trusted voice for advanced technology
ExploreA Drupal powered multi-site, multi-lingual platform to enable a unified user experience at SEMI
ExploreGreat Southern Homes, one of the fastest growing home builders in the US, sees greater results with Drupal
Explore View all Case StudiesTalking Drupal: Talking Drupal #390 - Employee Owned Companies
Today we are talking about Employee Owned Companies with Seth Brown.
For show notes visit: www.talkingDrupal.com/390
Topics- What is employee ownership
- Why did Lullabot choose this path
- What is the process
- Other examples
- Has it improved the culture
- Are employees more engaged
- Retirement
- Why don’t more companies do this
- Favorite part of working at an employee owned company
- Least favorite part of working at an employee owned company
- Favorite part as CEO
- Does it reduce pressure
- Tugboat / Drupalize.me
- How to get started
- Lullabot.com
- Planted game
- Employ owned companies
- Stake in the outcome by Jack Stack
Seth Brown - https://www.lullabot.com/about/seth-brown
HostsNic Laflin - www.nLighteneddevelopment.com @nicxvan John Picozzi - www.epam.com @johnpicozzi Jacob Rockowitz - www.jrockowitz.com @jrockowitz
MOTW CorrespondentMartin Anderson-Clutz - @mandclu Entity Registration Allows users on your Drupal site to register for events as an example, but really anything that’s an entity.
ComputerMinds.co.uk: Migrating cropped images
One of our big Drupal 7 to Drupal 9 migration projects included bringing across image cropping functionality and data on a longstanding client's website. This site had used the Imagefield Crop module, but that was only for Drupal 7. We set up Image Widget Crop for the new site, which is better in a few ways but is also fundamentally different. The old site referenced the cropped images from content, only bringing in the originally-uploaded images for edit pages, to allow editors to adjust the cropping, which was then used wherever that image appeared on the frontend. The new Image Widget Crop module, however, allows configuring different crops for different situations. For example, the same image could be cropped one way for use as a widescreen banner, but another way for when it appears in a grid of squares (as in the following screenshot).
The real challenge was in migrating the data! But we call ourselves Drupal experts, so of course we dug to find solutions. What we came up with might not work for everyone, but hopefully sharing this might help someone else that might be close enough to our situation. We found the following steps were necessary...
1. Set up the new configurationConfigure the crop types, cropping settings, fields and widgets etc for the Drupal 9 site to use, including an image media type. I won't go into detail here as there are already guides about how to do this - e.g. from the Drupal Media Team and OSTraining. What I'm focussed on is how to migrate the cropped images and their original files, and the references to use them in the right places.
2. Migrate files, including media entities, and references to themThe old site's files can be migrated into the new site easily enough. I then use the Media Migration module to create media image entities that reference those files. In my situation, it was fine to migrate the file IDs over and to use matching media IDs too. I expect this won't be an option on some projects but it made things much easier for me.
The Media Migration module uses 'dealer' plugin classes to cover different types of media, but its 'image' dealer plugin ignores images handled by Drupal 7's Imagefield Crop module. So I had to replace that with a custom plugin.
In general, I aimed to migrate the originally-uploaded image files (i.e. from before cropping was applied), and reference those from host content. That's how the new Image Widget Crop module usually references the images, whereas the Imagefield Crop module referenced the cropped image files. The Image Widget Crop module usually maps to the cropped images via the chosen 'crop type' referenced in image styles so that different crops can be used for the same field when output in different places. Therefore, any migrations for it will have to translate back from the IDs of cropped image files to the IDs for 'uncropped' ones.
A custom module's hook_migrate_prepare_row() did that file ID translation, and also skipped migrating cropped images as media entities. Since the cropped images won't be referenced from content, they would just clog up the media library as duplicates of the original uncropped images. Detecting which files were only cropped images that wouldn't be referenced from elsewhere was a bit tricky, and one of the slowest parts of my migrations. So I allowed file entities to be created for these cropped images, as I figured that didn't matter so much. I imagine these two bits could have been done better with specific plugin classes rather than this hook.
For migrating the right data into the media field on every node/entity that referenced croppable images, I made a custom process plugin to make use of that mapping of cropped-to-uncropped file IDs. So my node migration YAML files declared this plugin should be used to get the uncropped file ID on the destination, that corresponded to the cropped images' IDs on the source end, like this:
field_image: plugin: MYMODULE_precropped_image source: field_imageThat plugin basically just looks up the ID of the cropped file from the translation map that was set by the hook_migrate_prepare_row() and returns the ID of the uncropped image file.
3. Migrate cropping dataI needed additional migrations for the data in every Imagefield Crop field about the dimensions and positioning of the crops themselves. These created 'crop' entities, using a custom source plugin for a database table that extended Drupal\migrate\Plugin\migrate\source\SqlBase. This allowed me to use a bundle filter in my migrations, so different crop types could be used in Drupal 9 for images on different content types that happened to use the same source field storage in Drupal 7. The YAML for these migrations is simple enough to share:
langcode: en status: true dependencies: module: - crop - MYMODULE id: d7_crop_field_image class: Drupal\migrate\Plugin\Migration migration_tags: - Content migration_group: migrate_drupal_7 label: 'Image crops from field_image, except for galleries' source: plugin: MYMODULE_imagefield_crop_table field_name: field_image bundle_filter: - article - blog_post constants: crop_type: 4_3_landscape target_entity_type: file process: type: constants/crop_type # Our source plugin sets precropped_fid. entity_id: precropped_fid entity_type: constants/target_entity_type uri: uri height: field_image_cropbox_height width: field_image_cropbox_width x: plugin: callback # The D7 module recorded the co-ordinate of the top left of the crop box, # whereas we want the co-ordinate of the very centre of the crop box. callable: MYMODULE_translate_crop_coordinate unpack_source: true source: - field_image_cropbox_x - field_image_cropbox_width 'y': plugin: callback callable: MYMODULE_translate_crop_coordinate unpack_source: true source: - field_image_cropbox_y - field_image_cropbox_height destination: plugin: 'entity:crop' 4. Mitigate missing features in the new siteThe old and new modules have their own different approaches, which means they don't quite have feature parity. I actually think the new Image Widget Crop module has a better overall approach but our old site did make use of some settings unique to Imagefield Crop which we wanted to bring across. Most interestingly, as many of the old site's image fields were configured to use the same dimensions or aspect ratios, we could set up crops on the new site to be shared across those fields. However, there were a few fields that had slightly different constraints on 'input' despite appearing the same on 'output'. So we had to alter Image Widget Crop's widget (via two levels of #process Form API callbacks!) to apply different maximum post-cropping dimensions for certain contexts. Editors could bypass this fairly easily, but it covers the most common journeys that they would normally follow.
Mission accomplished!After all that, you can probably see it was quite a complex challenge! A lot of code went into this, which I have shared barely any of here but if you find yourself in a similar scenario and need help, get in touch or leave a comment here. If anyone actually needs the PHP or YAML code, maybe I can look at packaging it up to share. But I know it's probably not generic enough to cover everyone's situations - I'd love to contribute it back to the community otherwise.
The Drop Times: A Stitch in Time Saves Nine
Today, a Telugu-language movie got the Academy Award for best original song at the Oscars. While accepting the award, music composer M. M. Keeravani mentioned that he grew up listening to the Carpenters. Although he meant Karen and Richard Carpenter, the American music sensation of the '70s, three major media houses in Malayalam, another south Indian language, translated it as woodworkers.
It should be a classic example of shoddy journalism. But such mistakes are not so uncommon in vernacular media. The phrase 'prima facie,' was once misconstrued as a lady's name. One hundred eighty-six people sleeping in the railway station had washed off in a flash flood in an old story when in reality, it was sleepers on which the rails were paved. The word magazines got mistranslated as the literal monthly magazine in a story about the seizure of arms from the Sri Lankan Tamil militia. However, the editor saved the grace by finding it out before printing. While reporting a death after a 'hot dog' eating competition, a newspaper thought the man had eaten raging canines. If this is how journalists write, a techy said he would be in danger if he told Python is his bread and butter.
Now excuse me. It is the new normal. Our media houses have lost editorial prowess. Speed before accuracy is the new-age motto. In such a speed-crazy world, having your editorial arm halved would be a significant loss.
We at TDT have witnessed such a loss. As mentioned in the last newsletter, NERD Summit, and DrupalCamp NJ will happen this week. As media partners for the two camps, we had many plans to execute. And a significant part of the plans revolved around a young journalist we had just hired, S. Jayesh.
S. Jayesh is a name heard in both Malayalam and Tamil literary circles. He is a poet and short story writer who translated a few novels from Tamil to Malayalam. I knew him from his previous stints, where he was a workaholic and punctual, more productive than most, but would never do overtime as was the common practice in this part of the world. A polyglot having years of experience in online media, we hired him by the end of December.
On February 13, he fell on his back, involuntarily wounding his head. He was rushed to the hospital, had to undergo two neuro surgeries as his blood clot in his head, and was in a coma stage for more than two weeks. Fortunately, he has regained consciousness but must remain in the hospital. As he lacks medical insurance, his mother has taken to alms to fund his hospitalization expenses. She is seeking around $18,300 in USD or ₹1,500,000 in INR. Until now, she could collect only 32% of the same. Even if he gets discharged, it will probably take months for him to rejoin work. So we urge the Drupal community to pour your hearts in small amounts to help him in need.
The crowdfunding request is placed on Milaap.org, a fundraising platform for medical emergencies and social causes. The platform charges no intermediary fees, and every penny donated to Jayesh will go into his mother's account for the treatment of her son.
Coming back to the past week's stories. On March 08, Wednesday, we published an Interview with Rick Hood as a primer to the NERD Summit 2023. In this exciting interview, he not only discusses Drupal but also goes into his music production interests and his past boat business.
Evolving Web has announced a training on Drupal Site Building in April. On March 15, Acquia will host a webinar on Securing The Modern Digital Landscape, and on March 16, another webinar on CDP. Tomorrow, Design4Drupal Boston will host AmyJune Hineline for an accessibility webinar.
All but three sessions of DrupalCamp Florida are online on their YouTube channel. MidCamp 2023 has announced its sessions and speakers. DrupalCamp Finland started accepting papers. NERD Summit was still accepting training session submissions as a backup. They have also pushed out a call for volunteers. DrupalCamp Poland has put early bird tickets on sale. DrupalCon Pittsburgh is seeking sponsors to support Women In Tech. The last day to apply for a volunteering opportunity in DrupalCon Lille is tomorrow.
Project Browser Initiative collects feedback via google forms about what information is most valuable to you when "browsing" for modules on drupal.org. In celebration of Women's history month, Drupal Association highlighted the work of Nichole Addeo, the Managing Director and Co-founder of Mythic Digital. ICFOSS and Zyxware Technologies joined hands to impart Drupal training for women as part of the' Back to Work for Women' campaign.
On blogs and training materials, visit Kevin Funk's article in Acquia Developer Portal about utilizing developer workspaces with Acquia Code Studio. Alejandro Moreno Lopez, the Developer Advocate at Pantheon Platform, shared an educational video about the benefits of using Drupal for a Decoupled project.
That is for the week. Thank you,
Sincerely,
Sebin A. Jacob
Editor-in-Chief
Mike Herchel's Blog: Creating Your First Single Directory Component within Drupal
ImageX: From Discovery to Post-Launch: The Ultimate Guide to a Web Project
In today’s digitally-focused world, it’s nearly impossible to do business without a presence on the world wide web. In fact, your website should be a cornerstone of your marketing efforts and a primary tool for reaching your audience.
For your site to effectively drive your business forward, it needs to be well-constructed and consistently maintained. That’s a big job. And it needs the right partner.
Our four-part process for website development is a proven approach to building an impactful online presence. Our ebook outlines the expectations and considerations for each distinct phase — Discovery, Design, Development, and Post-Launch — so that you are well-prepared to build a website that will serve your business now and into the future.
/sites/default/files/styles/original/public/2023-03/pexels-rodion-kutsaiev-9436715.jpg.webp?itok=isGsjHz3 Feature as an event Off Service Category Design UX Design User Research Journey Mapping Web Design User Personas Usability Testing Strategy Discovery Website Audit Workshops Training Storytelling Analytics Digital Marketing Develop Evolve Site Growth Drupal CMS Support IsGated 0 IsDownloadable 1 Attachement link https://marketing.imagexmedia.com/acton/attachment/43677/f-1ffcfc1b-3705-49fa-b320-a060caa98e08/0/-/-/-/-/From%20Discovery%20to%20Post-Launch%3A%20The%20Ultimate%20Guide%20to%20a%20Web%20Project.pdfmark.ie: Creating different styles for subsites within a Localgov Drupal website
We've had lots of requests for changing the design of subsites in LGD. Here's how I'd do it.
clemens-tolboom opened an issue in MikeSchulze/gdUnit4
The used GdUnit4 version: Downloading directly from https://github.com/MikeSchulze/gdUnit4/archive/refs/heads/master.zip The used Godot version: O…
ImageX: International Women’s Day: An interview with the team
This year’s IWD’s theme is #EmbraceEquity. This should remind everyone everywhere about the importance of creating a genuinely inclusive society, challenging gender stereotypes, and calling out biases.
In the ImageX team, we are wholeheartedly aligned with these values and committed to fostering a truly equitable workplace. Even though tech is seen as a male-dominated industry, the Women of ImageX are key drivers behind the success of our organization. In celebration of this year’s day, we’re showcasing some of our team who are leaders in their areas; Mahya Golabi [design], Carol Pettirossi [development], Alla Petrovska [operations], and Kylie Aldridge-Ogden [delivery]. These four women are just a small snapshot of the awesome talent we are fortunate to work alongside everyday at ImageX, with each and every one of our women leading the way in their roles within a male dominated industry.
Getting acquainted: roles and backgroundsTo start, the team shared their roles and how they ended up where they are today:
Carol, Software Architect: “I’m a female Drupal Architect that has been working in the Tech industry for 14 years. I started creating websites back in the day of blogs.
I studied programming in high school which gave me the opportunity to start my tech career before getting a university degree. I love working with sites and platforms, building the best experience for users so they can find information and perform tasks digitally whenever possible.”
Alla, HR & Operations Manager (Ukraine): “ I’ve been with the organization for 6 years already and being an explorer in my soul with a love to connect the right people with each other and make things work, I find ImageX the perfect match for me. It is a place with a multicultural team distributed over the globe where diversity is well represented."
Kylie, Senior Portfolio Director Not-For-Profit: “My passion lives in working with non-profits. I have served on a few Non-Profit boards throughout my career, spending seven years as Director at large for a national non-profit. At ImageX, I oversee the execution of all Project and Support Agreements within the vertical.” Mahya, Lead Designer: “I started with ImageX as a UI designer back in 2018. At that point, the design team only consisted of another designer and me, and there were only a handful of female employees here at ImageX, it’s incredible how that has evolved as we’ve grown.” Talking about the meaning of IWDWe then asked the team why International Women's Day is important to them.
Mahya: “As an immigrant, I believe, recognizing and celebrating the contributions of immigrant women to society can help promote inclusion and reduce stereotypes and prejudices. It can also provide a platform for immigrant women to share their experiences and advocate for their rights.
I think Women's Day serves as a reminder that women, regardless of their background, deserve equal rights and opportunities.”
The importance of diversity in the workplaceWe were curious to know what the group thinks about diversity in the workplace, especially as it’s one of the intrinsic values of our international team.
Carol: “Women, as well as other underrepresented groups, bring diverse skill sets, viewpoints, and experiences to the workplace. Different cultures and experiences are proven to help businesses function better and also improve their processes. Each employee has their individual strengths and potential. Valuing the differences of others is what ultimately brings us all together and can be the secret to a successful, thriving workplace and a fair work culture.”
Mahya: “As a creative person, in my view, diversity brings in creativity and innovation: When people from different backgrounds and with different experiences work together, they bring different perspectives and ideas to the table. This can lead to more creative and innovative solutions to problems.”
Sharing their role modelsMany women have a role model who inspires and drives them toward greatness. So who are the role models for the women of ImageX?
Kylie: “From a professional standpoint, Sheryl Sandberg, the COO of Meta is one role model. I was introduced to her through her book, Lean In, which was recommended to me by a former male boss. Sheryl has a belief that echoes mine — if you’re going to have a family, make sure there is equity in the household. Another role model of mine is Heather Reisman, the CEO of Indigo. She was the first major female CEO in Canada and as an avid reader, I always kept an eye on her work. From a personal standpoint, my role model is my mother. I’ve always had a working mother and as a daughter, that is an amazing thing to witness.”
Mahya: “My mother is a strong entrepreneur who started as a teacher and now owns and directs three schools. She has shown me how to be an independent, strong woman when you are confident, resilient, and self-sufficient.”
Carol: “It would also be my mom. She is a symbol of resilience to me. She had a difficult upbringing and had to stop studying early. However, she overcame the difficulties and after I was born she decided to restart studying and become a nurse. She does night shifts at the hospital but she always enjoyed her job and taught me how important it is to love what you do.”
Alla: “My role model is all Ukrainian women: on the front line of the battlefield, or cultural, political, and social front lines — they all are fighting now for democracy, equity, freedom, and protection of human rights.”
Advice to women at the beginning of their careerIt can be challenging to start a path in a new professional field, especially as a woman. How can women grow professionally and fight gender stereotypes in the workplace?
Alla: “Listen to yourself and seek a role model or mentor. If you fail, learn from it - it is your opportunity to grow, don’t skip reflecting on it, as most likely you’ll fail over the same thing again in the future; have a plan…and a back-up plan.”
Kylie: “Never feel guilty to ask for what you need. While the pay gap is narrowing, more often than not, women who don’t get pay rises that mirror their male peers because they don’t ask for it. Make sure you advocate for yourself. Also, don’t internalize the labels and tropes that women are given in the workplace. For instance, “women are bossy while men are bold” or “women are emotional, men are direct”. We don’t need those, they’re not for us.”
Empowering other women in the workplaceWomen can empower other women, lift them up, and help them grow. Together, they can be an invincible force. The women of ImageX have shared some useful ways they look toto empower other women in the workplace:
Carol: “Providing mentorship and training to develop junior women into senior and leadership roles. Making sure that they are heard and have a seat at the table. Making sure that there is an open communication mechanism for women to report on situations that they feel undervalued or not heard.”
Alla: “Be yourself, accept and respect others individuality; speak openly (everyone has their own strong and weak sides — be open about them); treat everyone fairly; be approachable, offer help and be ready to back up; don’t be afraid of speaking about the failures; celebrate wins together!”
Dinner with three inspirational womenAsking everyone to choose three inspirational women, dead or alive, that they would have dinner with was one of our favourite talking points.
Kylie: “I couldn’t narrow it down to 3 so I have four:
1. Mary Wollstonecraft — She was the leader of the suffrage movement in England. She was fighting to make women people under the law. She was one of the pioneers that laid the groundwork for where we are today;
2 & 3. Gloria Steinem & Ruth Bader Ginsberg — Two feminist icons who have done more for gender equity and advocacy than anyone else. We wouldn’t have half the rights we have now without these two women. They worked together and were longtime allies, you can't have one without the other.
4. Michelle Obama — Who wouldn't want to have lunch with her? She built herself a platform and never took it for granted. She comes across as so humble and down to earth, and yet has this huge and beautiful platform that she uses for positive change.”
Carol: “1. Gloria Maria: She was a black Brazilian journalist that always talked about women being empowered. She represented the black community and had racism and feminism in her agenda. She also traveled around the world reporting different cultures. Can you imagine how wonderful a chat would be with her?
2. Susie Wolff: She is the Director of Formula 1 Academy and a former racing driver. She is now responsible for nurturing female talents in the sport. In such a male dominant field, it would be great to have dinner with her and learn how she deals with the challenges on a daily basis.
3. Helena Rizzo: She is one of the best chefs in the world and the only Brazilian female chef leading a restaurant awarded with a Michelin star. Gastronomy is another field dominated by men and she excels in it. She is also involved in many charity and feminist initiatives.”
How organizations can #EmbraceEquityThe ultimate question that wrapped up our conversation was related to the IWD 2023’s #EmbraceEquity campaign theme. How do the team feel that organizations can create a culture which supports equity?
Kylie: “I read a 2022 study from PwC on Global Workforce Hopes and Fears. The largest workplace cultural contribution to equity that can be done is for a workplace to offer flexibility of schedule. One of the things that ImageX has done well is not only offer that but stand by it — giving their employees a flexible schedule and keep pushing equity forward. At ImageX, we do it without gender labels or bias, so that nobody is penalized.”
Mahya: "In my opinion it should be two areas:
1. Promoting transparency
2. Identify biases in the organization and address them"
Alla: “Organizations can create a culture of equity by embracing it from the top — ensuring equal support and opportunities during the recruitment process; giving equal access to development opportunities upon employment; nurturing a strong sense of belonging to the workplace where differences are celebrated.”
Carol: “Providing an open communication culture where women in any position can admit to past failures and vulnerabilities without being judged. This culture paves the way for other women to have confidence that women in leadership are not super powerful. It helps everyone to understand that you can be yourself, you can fail, you can have feelings. An empowered woman doesn’t mean a Flawless and Perfect woman.”
And That’s a Wrap!We are very grateful to Kylie, Mahya, Alla, and Carol for this wonderful conversation. Hopefully, their insights and answers resonate and shed light on gender equity, diversity, and the need to empower talented women in male dominated industries.
Wishing everyone a Happy International Women's Day!
/sites/default/files/styles/original/public/2023-03/pexels-hasan-albari-1141678%20%281%29.jpg.webp?itok=_BM3l2ya Blog Category ImageX Feature as an event Off IsGated 0 IsDownloadable 0 ImageX Updates NewsGolems GABB: Illustration with Shapes
We are so interested in who you are. Are you a designer? We can suppose it as you are interested in this topic. However, it can be assumed that you are not. Basically, you may not even be related to design, and the last time you drew was in school. Did we guess? Whoever you are, we've written this blog for you!
Specbee: How to Efficiently Fetch Drupal Reference Entities in Custom Modules
Fetching Drupal entities and fields in custom modules is a critical part of building complex Drupal applications that require custom functionality. By understanding how to access and manipulate entities and fields programmatically, developers can create powerful and flexible modules that can handle a wide range of data-driven tasks.
In this article, we will share tips and easy methods on fetching reference entity fields using entity API that will help you simplify your custom module development process.
Getting Back to Basics What are Entities?Entities are the most core part of Drupal and it is important to understand what they are and how they work. They are objects that represent anything from users and nodes to taxonomy terms. Each entity has their own properties and can be customized or extended to fit the needs of a website.
What are Fields?Fields make it easy to manage complex content structures. They are used to collect and display a variety of data like text, images, date and more which can be associated with an entity. For example, a content node can have multiple fields like a title, summary, body, image etc.
What are Nodes?A node is a basic unit of content in Drupal. It can be a blog post, a product, a news article or an event. Each node has its own properties and can be organized into different types (or content types). A node can be used to create, edit, delete or categorize content.
Drupal Entity Reference FieldsEntity reference fields provide relationships between entities in Drupal. It stores references to another entity (a node, user, taxonomy, etc.). An example of a relationship would be:
- A taxonomy term associated with a content type or user account.
- A parent content that references a child content element.
It is commonly used in views and adding view relationships makes it quite easy to use reference fields. But the problem arises when fetching values of the reference fields in your custom module and custom theme.
The common method used to get a referenced entity is very long, so I will take you through a shorter solution.
For example, let's say we have a node object with a reference taxonomy field named field_specbee_term.
How it is usually done:
Method 1: // $id = Node ID // $field = 'field_specbee_term'; // field name for term reference field $node = Drupal\node\Entity\Node::load($id); // To get first value from multivalue field used first() method. $reference_item = $node->get($field)->first(); // \Drupal\Core\Entity\Plugin\DataType\EntityReference. $entity_reference = $reference_item->get('entity'); // \Drupal\Core\Entity\Plugin\DataType\EntityAdapter. $entity_adapter = $entity_reference->getTarget(); // \Drupal\Core\Entity\EntityInterface. $referenced_entity = $entity_adapter->getValue();Here, $referenced_entity is the referenced entity object.
Now alternatively, instead of using the above tedious method 1, here is an easier way of doing it.
Method 2: $referenced_entity = $node->field_specbee_term->entity;However, if you want to fetch all the values from the multivalue field, Method 2 will not work.
For loading the entire list of reference entities as objects will use the below method which is a type of array.
$referenced_entities = $node->get('field_specbee_term')->referencedEntities();This method can be used for image reference as well.
Let’s see an example of how we can get an image URL from a node with a specific image style.
// $fid = File ID $file = Drupal\file\Entity\File::load($fid); // Alternatively you can use direct node field. $file = $node->field_image->entity; $image_uri = $file->getFileUri(); // Get origin image URI. $style = ImageStyle::load('thumbnail'); // Load image style "thumbnail". $uri = $style->buildUri($image_uri); // Get URI. $url = $style->buildUrl($image_uri); // Get URL.Now let’s understand how to retrieve any field values and which method is preferred for different scenarios.
// $id = Node ID $node = Node::load($id); $node->get(FIELDNAME)->value; // ALL VALUES - WON'T WORK IN REFERENCE FIELDS $node->get(FIELDNAME)->getValue(); // ALL VALUES $node->get(FIELDNAME)->getString(); // ALL VALUES1. value :
This will return the actual value of the field but it will not work for any referenced field.
2. getValue() :
When you need to get values of a field, whether it is a single-value or multi-value field, you can use this method. It will return an array of field values.
3. getString() :
This method will return the value of a single-value field, and if it is a multi-valued field it will return comma-separated values.
Note: Sometimes when using getString(), if there is no value present, it will throw an error. This can be tackled by using the hasvalue() function before using the getString() function.
Final ThoughtsFetching Drupal reference entities is an essential skill for Drupal developers. With the Entity API, you can easily load and manipulate entities and their fields, making your custom module development process more efficient and streamlined. However, if you need expert assistance with Drupal development, our team of experienced developers is here to help. Contact us today to learn more about our Drupal development services and how we can help you build powerful Drupal websites and applications that meet your unique needs.
Author: Jigish Chauhan
Meet Jigish Chauhan, Technical Architect, who’s fond of photography. He dreams of traveling to the playground of Europe, Switzerland, and loves to embrace the nature around him.
Email Address Subscribe Leave this field blank Drupal Drupal Module Drupal Development Drupal PlanetLeave us a Comment
Recent Blogs Image How to Efficiently Fetch Drupal Reference Entities in Custom Modules Image Finding Balance - Santhosh Kumar's Parallel Worlds Image Migrate to Drupal 9 (or 10) Without Losing Your Hard-Earned SEO Ranking Want to extract the maximum out of Drupal? TALK TO US Featured Case StudiesUpgrading the web presence of IEEE Information Theory Society, the most trusted voice for advanced technology
ExploreA Drupal powered multi-site, multi-lingual platform to enable a unified user experience at SEMI
ExploreGreat Southern Homes, one of the fastest growing home builders in the US, sees greater results with Drupal
Explore View all Case StudiesComputerMinds.co.uk: Drupal 10 upgrade: Custom code upgrades
This one is entirely on us, we wrote the custom code, which makes us responsible for maintaining it.
The upgrade status module gives us a nice report of each custom project and what changes it thinks are required to bring the code up to date to work with Drupal 10.
We really don't have a lot of custom module code, and the code that we do have is very simple, standard Drupal 8/9/10 stuff, so there are a couple of calls to taxonomy_term_load_multiple_by_name to remove, and an accessCheck to add to an entity query, but other than that our custom module code looked fine.
Our custom theme however, is a different story: we have some usages of jQuery once to remove, and we have a lot of custom Twig PHP classes that are extending deprecated classes. Nothing show-stopping, but a few things to do worth covering in more detail.
jQuery onceThe jQuery once plugin has gone from core in Drupal 10, so we need to upgrade our javascript that is using it to use the vanilla javascript alternative that ships in Drupal 9: the once plugin. This is simple enough, we can rewrite code like this:
(function($) { Drupal.behaviors.smoothScroll = { attach: function (context, settings) { $('a[href*="#"]:not([href="#"])').once('smoothscroll').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { var offset_height = target.offset().top; $('html, body').stop().animate({ scrollTop: offset_height , }, 1000); return false; } } }); } }; })(jQuery);Into code like this:
(function($, Drupal, once) { Drupal.behaviors.smoothScroll = { attach: function (context, settings) { var elements = once('smoothscroll', 'a[href*="#"]:not([href="#"])', context); $(elements).click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { var offset_height = target.offset().top; $('html, body').stop().animate({ scrollTop: offset_height , }, 1000); return false; } } }); } }; })(jQuery, Drupal, once);And then we need to tweak the definition of our library in the corresponding .libraries.yml file to remove the dependency on core/jquery.once and add one on core/once.
Twig changesAs mentioned previously the site was originally built in Drupal 8, which meant using Twig version 1, so there are plenty of deprecations to take care of to get the codebase ready for Drupal 10.
This is largely because we have a slightly strange setup in that we're using an early version of Emulsify to build our theme. Most importantly for this article it means that our theme contains quite a few twig functions like this:
<?php /** * @file * Add "getUniqueId" function for Pattern Lab. * * Brings the useful Drupal Html::getUniqueId function in. */ use Drupal\Component\Utility\Html; /** * Create the function we want to be able to call. * * Our function will be passed $context and then any other values provided. */ $function = new Twig_SimpleFunction('getUniqueId', function ($context, $string) { if (is_string($string)) { // Must cover the Drupal context AND the PatternLab context. if (class_exists('Drupal')) { return Html::getUniqueId($string); } else { return $string; } } else { return $string; } }, ['needs_context' => TRUE, 'is_safe' => ['html']]);This can trivially become (changing the base class that is extended):
<?php /** * @file * Add "getUniqueId" function for Pattern Lab. * * Brings the useful Drupal Html::getUniqueId function in. */ use Drupal\Component\Utility\Html; /** * Create the function we want to be able to call. * * Our function will be passed $context and then any other values provided. */ $function = new \Twig\TwigFunction('getUniqueId', function ($context, $string) { if (is_string($string)) { // Must cover the Drupal context AND the PatternLab context. if (class_exists('Drupal')) { return Html::getUniqueId($string); } else { return $string; } } else { return $string; } }, ['needs_context' => TRUE, 'is_safe' => ['html']]);The codebase has around 20 usages of deprecated Twig classes, however the task looks simple enough and there's nothing particularly tricky to do here, simply tweak the classes used per the deprecation messages in the older classes. There are automated tools that'll make these changes for you, but to be honest, there aren't that many changes to make and I'm keen to get eyes on the codebase more generally and get a feel for what we have in it!
All doneSo that's it for Custom code and theme. We had actually been pretty good at:
- Not writing custom code unless we had to.
- If we did write custom code, not using already deprecated code.
- Going back periodically and remediating new deprecations.
Which then makes these changes pretty straightforward.
Aside: I'll just note that we have a lot jQuery style JavaScript in our codebase....mostly because we've been around for a while and learned JavaScript with jQuery, so it's just too easy for us to still write with jQuery everywhere. However, we know that we need to get to a place where we don't need jQuery and we'll get there, but we'll need to do some internal training on that and then go back through our code and re-write it without jQuery. Maybe I'll write an article about that too one day!
Annertech: 8 tips and tricks for making migration easier
Migrating at scale isn't for the faint of heart. Senior developer Erik Erskine reveals some neat tips that will ensure that your next migration is easier than you expect.
Annertech: Migrating at scale? These are the tools you need to use
Migrating at scale is daunting, but the right tools can make it easier. In this blog we draw on our experience from migrating 50 sites in one go.