Drupal Association blog: Find Community at DrupalCon Pittsburgh 2023

DrupalCon is a community event, where people from around the world can come together and share in the mission to make Drupal the most impactful DXP in the world. Even beyond that, DrupalCon is for many people the one time a year to connect in person with the people they work with every day. We are so excited to share all the places where the community can connect in June! 

Community Summit 

Join us on Thursday, 8 June at DrupalCon Pittsburgh for a full-day unconference dedicated to exploring the issues that matter most to the Drupal community. What’s an unconference, you ask? It is a loosely structured conference that emphasizes sharing information instead of following a conventionally structured schedule. Together we will select topics that matter most to attendees and have collaborative discussions throughout the day. 

RSVP

There is a lot more information about unconferences online - Here are some great tips on how to prepare to attend an unconference. Please feel free to contact the organizers if you have questions: 

Who should attend?

You! Are you part of a Drupal community or want to start one in your city? This summit is meant to be a meeting place for all Drupalistas interested in the community. Whether you need help maintaining a long-standing camp or User Group, you’re new to the community and want to know where you can get involved, or you want to share a success story from your community, everyone is welcome.

What gets discussed?

In the morning: 

Presentations on the latest work being done from some of the Community Initiative Leads. Check out the detailed schedule page for session descriptions! 

In the afternoon: 

You decide! Topics at past events have included:

  • Contributing to the community
  • Organizing events
  • Improving diversity
  • Growing local communities
  • How to prevent burnout
  • How do we foster and grow mentorship programs

But it all gets decided on the day, by whoever is in the room.

The community summit isn’t all about talk, it’s about action as well. Networking is a powerful force for collaboration.

Check out the detailed schedule

Community summit success stories

Several initiatives have started as a conversation at past community summits:

  • The Event Organizer Working Group
  • Speaker Diversity workshops
  • Internship programs

Please RSVP and let us know what you’d like to discuss!

Community Initiatives 

Come by the community booth in the expo hall to learn more about Drupal Community Initiatives and how you can get involved! 

Social Events 

Social events are often where the magic happens at DrupalCon. Whether it’s a small group hike, coffee hang-outs, or organized parties by our amazing partners, social events help foster lifelong connections. Check out the social events page to stay up to date on what’s happening around the city during DrupalCon, and even submit one yourself! 

Social events at DrupalCon

Decompress 

The festivities at DrupalCon can be overwhelming at times, and it can be hard to find a space to be in community quietly. For a respite from the hustle and bustle, visit our Quiet Space, Non-Denominational Prayer Space, or rooftop terrace. 

Quiet Space - Room 313

This room is reserved for those who need space free from interaction with other participants in an environment where they feel free and safe to do so. The quiet rooms are free of conversation and interaction of any kind. They can be used for meditation, journaling, reading, or just silence away from the buzz of the Con. Soft seating, stimming tools, and relaxing art supplies are provided. 

Image removed.

Non-Denominational Prayer Space - Room 314

This room is reserved for those who wish to practice their faith in a quiet and respectful environment. Spiritual texts and prayer rugs are provided. We ask that participants use hushed voices when necessary, but practice silence as much as possible to respect other attendees who may be using the space.

Image removed.

Rooftop Terrace 

Relax in green space without having to leave the DLCC. The rooftop terrace overlooks the Duquesne River, and you’ll have a view of many of Pittsburgh’s bridges. Enjoy the sounds of the water below, or take a stroll along the Rooftop Boulevard, where gentle tones play from the speakers above. If you take a look at the swooping art fixture, you can also find inspiration quotes scrolling digitally. 

Image removed.

No matter how you like to be in community, there’s a place for you at DrupalCon. We can’t wait to share space with you! 

Matt Glaman: Creating fields programmatically and not through field configuration

Drupal is great for its content (data) modeling capabilities with its entity and field system. Not only is this system robust, but it is also completely manageable from a user interface! When fields are created through the user interface, they are managed through configuration. Drupal automates all schema changes required in the database based on this configuration when it is first created or when it might be removed. I have always had one issue with managing fields through configuration – your business logic relies on trusting that no one modifies this configuration. I prefer to define my fields programmatically, ensuring they exist and that fields tied to business logic are always present. Of course, this means I must also manage their installation and deletion for schema changes. But I prefer that level of control.

Specbee: Customizing Content Display in Drupal: A Guide to Display Modes

Customizing Content Display in Drupal: A Guide to Display Modes Pratik 04 Apr, 2023 Subscribe to our Newsletter Now Subscribe Leave this field blank

The primary function of a CMS is to create and manage content, as well as to allow users to search, customize, and publish content. The way your content is presented can decide how easy or difficult it is to use your website. In Drupal, display modes are different ways of presenting your content on your website. For example, you can show all the information about an article on a website, like a title, author, date, and full text, or you can show just a summary of it. Display modes let you choose what information you want to show and how it's arranged.

Display modes are built into Drupal core and they provide an easy way for developers to control how their content appears on the page. Content types in Drupal provide different types of display modes, each with its own features. For example, nodes (content pieces) can have multiple displays, such as teaser, full, list, and even a custom view. While some content types are limited to one display type (e.g. single page), other content types can have multiple display modes.

This article will help you get a deeper understanding of display modes, their uses, applications and extensions. So let’s get started!

Image removed.

What are Display Modes

Display modes are one of the core features of Drupal that help us manage the display of content and form entities differently for different situations. Content entities include taxonomy, nodes, paragraphs, and forms to add/edit content entities.

Similar to other configuration entities, like content types, display modes can be exported and imported as configuration files(.yml). Display modes have two parts, view mode, and form mode.

Why use them?

Display modes are just one of the many features that make Drupal great, and they provide users with a way to customize their websites by allowing them to control how different types of content are displayed on their sites. It also helps: 

  1. Render content on the page only when required. The fields we don't need can be skipped.
  2. Increase site performance.
  3. Reduce the necessity to create multiple or duplicate content.

Working with Display Modes

Display modes can be accessed from structures.

Image removed.

 

As discussed previously, there are two types of display modes:

  1. View Mode
  2. Form Mode

Using the View Mode

View modes help to manage the display of the content item.
Different modes can be used to display different types of entities. Like view mode for taxonomy content can be used for taxonomies contents only. 

You can create new view modes or modify existing view modes.

To create a new view mode, click on “Add view mode” and choose the type for which you want to create the view mode. For example, select “content”. This will create a view mode for contents of a content type.

Image removed.

For configuring a view mode, go to the content type settings for which you want to use the view mode. Next, go to “Manage display”. At the bottom within “Custom display settings”, you can select any of the available view modes that you want to use.

Image removed.

Here we have selected three view modes. Next, save this configuration. You will then see that these view modes are visible in the “Manage display” tab.

Image removed.

You can make different configurations for displaying the content on the front end for each mode. For example, if you need to disable a field content or render it differently.

Few common use cases:

  1. Entity reference field
  2. View items
  3. Paragraphs

Form Mode

Form modes can be used to simplify forms for certain use cases, such as creating a simpler form for user registration, or to add additional fields and functionality to a form for more complex use cases. Most commonly, you want to display forms according to user roles.

Like view mode, you can create or configure your own form mode. If you want to use a form mode for a node add/edit form, you can do it in the “Manage form display”.

Form mode features will not work directly from the UI for all forms. If you need to implement for node forms, you have to do it programmatically.

If you want some easy UI options for using form mode we can use the Form mode manager and form mode control contributed modules.

Form mode Manager

After installing the module, you will see the form mode listed on the module configuration page.

Image removed.

Here you can manage which form mode to use for a user by providing permissions.

Image removed.

 

Form Mode Control

The module also simplifies the process of using form modes.

After enabling the module, you can see form modes on the configuration page. You can choose which form to use.

Image removed.

 

If you want to use the form mode for other user roles, you have to provide relevant permissions.

Image removed.

 

You can set up the user roles on the configuration page.

Image removed.

Final Thoughts

Features like display modes make Drupal a great CMS to work with as they provide a high degree of flexibility and customization for how content is displayed on your website. Display modes allow you to create different layouts and designs for your content, giving you the ability to showcase your content in unique and engaging ways. We hope this brief tutorial will help you understand and work with Display modes more effectively. If you like what you read here, consider subscribing to our weekly newsletter so you don’t miss out on any of our latest articles.

Author: Pratik

Meet Pratik, a Drupal developer by profession. He enjoys reading and is always eager to learn new languages. Someday, he would love to visit Italy, his dream travel destination. He enjoys diverse cuisines and has a passion for food.

Email Address Subscribe Leave this field blank Drupal Drupal Development Drupal Module Drupal Planet

Leave us a Comment

 

Recent Blogs

Image Image removed.

Customizing Content Display in Drupal: A Guide to Display Modes

Image Image removed.

How to Create Dynamic Layouts with Layout Builder, CTools, and View Modes

Image Image removed.

A Journey of Persistence - Shreeganesh’s Career Story

Want to extract the maximum out of Drupal? TALK TO US

Featured Case Studies

Image removed.Image removed.

Upgrading the web presence of IEEE Information Theory Society, the most trusted voice for advanced technology

Explore
Image removed.Image removed.

A Drupal powered multi-site, multi-lingual platform to enable a unified user experience at SEMI

Explore
Image removed.Image removed.

Great Southern Homes, one of the fastest growing home builders in the US, sees greater results with Drupal

Explore
View all Case Studies

Talking Drupal: Talking Drupal #393 - Drupal & Javascript

Today we are talking about Drupal & JavaScript with Andy Blum.

For show notes visit: www.talkingDrupal.com/393

Topics
  • Talk at FLDC
  • Important Drupal JS features
  • Drupal behaviors
  • Why use JS
  • Users with no JS
  • jQuery
  • Front end framework
  • Bigpipe
  • JS components single folder components
  • Future of JS in Drupal
Resources Guests

Andy Blum - @andy_blum

Hosts

Nic Laflin - www.nLighteneddevelopment.com @nicxvan John Picozzi - www.epam.com @johnpicozzi Kat Shaw - drupal.org/u/katannshaw @katannshaw

MOTW Correspondent

Martin Anderson-Clutz - @mandclu Real-time SEO for Drupal Provides content authors immediate feedback about how optimized their content is against specific keywords.

The Drop Times: Dear Readers, It Is All in Your Hands

It would be a slight change of scenery for you readers—an inexperienced writer in the works. I have always preferred people who knew what they were doing. Of course, from my stance, that preference would be because I want to learn. But when TDT’s editorial meeting puts confidence in a newcomer, and she is tasked to write a personal note to our avid readers, that sounds like an opportunity. And here I am grabbing that moment. 

Writing as a profession was revealed to me quite early on, but the art of writing is what I struggle with everyday. I don’t want to speak for everyone, but, to be honest, almost every writer could feel this way.

Now, I do have a simple plan. To observe is to learn. And my first target is to learn from my mentors. Taking my own advice and looking into what our Editor-in-Chief mentioned in a previous newsletter:

It is the baby steps that matter. And once you are thorough, it comes naturally to you. To reach that level need patience and practice. ~ VOL. 1 ISSUE. 7

The words, tone, structure of the sentences, references, and how the stories are told—Storytelling is a wonder. Has the media mastered the art of storytelling? A liar could have that skill as well. Apparently, it is all in the details, not too much or too little.

I think it is all perception and the power of discernment. It is in your hand, dear readers, all in yours. So, if you believe my writing is good and faithful, it could be. But if you don’t, it is all in your hands again. Until you decide, I’ll take you through what we have covered on TDT this past week.

I want to point out that writing a news story is a bit different. As you know, it is all about accuracy and facts. There aren’t many areas for storytelling, or are there? 

Now straight to the week’s stories. 

The DrupalCamp Poland proposals deadline is approaching soon, and the Drupal User Group Hamburg & Schleswig Holstein hosted an in-person meetup on March 30.

As the EoL of Drupal 7 nears, Chromatic released a Podcast that discusses the implications of Drupal 7 End of Life. Another exciting release was Droptica’s E-Book on SEO Strategies for Drupal Websites.

NERD Summit ended last month; here are the summit’s statistics: 2023 vs. before, excluding the covid years. DrupalSouth calls for a broad panel of judges for the splash awards. Fox Valley Drupal will host the midCamp preview and ramp-up. Acquia stands out as a leader in the 2023 Gartner Magic Quadrant for DXPs and SystemSeed Shortlisted for the 2023 Global Business Tech Awards.

There will be a Drupal4Gov’s in-person half-day seminar on April 18, so keep an eye out for that and also make sure to read an article shared on opensource.com, titled “How to encourage positive online communication in your open source community,

There is more to ramble on about, but these were a few favorites picked in all truth. That’s it for this week.

Sincerely,
Alethia Rose Braganza
Sub-Editor.

ComputerMinds.co.uk: How to: Implement an automated Commerce Order state transition

Image removed.

A common requirement for any website that sells products is to have a mechanism in place that ensures orders placed on the website are 'Exportable' - being made available as a file that can be sent across to a different system, to handle the processing of the order.

The Drupal Commerce 2.x module (for Drupal 9, 10) has the concept of order 'Workflows', along with defined 'States' and 'Transitions'. A workflow is a set of states and transitions that the order will go through during its lifecycle. Transitions are applied to an order and this will progress the order from one state to another. By default, a few workflows are provided but for sites that we build, we usually write our own order workflows to handle the specific requirements of the site in question.

Image removed.

A comparison of one of the default Commerce order workflows (on the left) and our own custom workflow (on the right). For more information about creating a custom order workflow, see the excellent documentation on drupalcommerce.org.

One common requirement that doesn’t quite work properly ‘out of the box’ is the ability for an order to be automatically transitioned to a separate 'exported' or 'completed' state, immediately after the order has been paid for successfully. We can achieve the desired functionality with a combination of an event subscriber and a useful entity update hook. Here’s what we did:

Step 1 - Implement the event subscriber.

We’ve already covered event subscribers before in a number of our articles so I won’t go into the specifics here, but the first thing we’ll want to do is create a new one that will be able to react to our Orders’ state transition.

N.B. In this example, we are assuming our custom code will live in a module that already exists, named ‘example_order_exporter’.

First off, we’ll add a new file inside of our custom module to handle our event subscriber. In the example code in this article, we’ll be naming it OrderExporterSubscriber.php and the full path it should live under is example_order_exporter/src/EventSubscriber/OrderExporterSubscriber.php

namespace Drupal\example_order_exporter\EventSubscriber; use Drupal\example_order_exporter\OrderExporter; use Drupal\state_machine\Event\WorkflowTransitionEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class OrderExporterSubscriber implements EventSubscriberInterface { /** * @var \Drupal\example_order_exporter\OrderExporter */ protected $orderExporter; /** * {@inheritDoc} */ public function __construct(OrderExporter $order_exporter) { $this->orderExporter = $order_exporter; } /** * The 'place' transition takes place after the order has been paid for in * full, so we'll subscribe to the post_transition event at this point. */ public static function getSubscribedEvents() { return [ 'commerce_order.place.post_transition' => ['onOrderPlace', -100], ]; } /** * Act on an order after it has been paid for. * * We simply set a success / failure flag for the export here, and then * handle the state change in a hook_commerce_order_update() implementation * as the previous state change to payment will have finished by that point. * * @see example_order_exporter_commerce_order_update() */ public function onOrderPlace(WorkflowTransitionEvent $event) { /** @var \Drupal\commerce_order\Entity\OrderInterface $order */ $order = $event->getEntity(); // Call our service to export the order. $exported = $this->orderExporter->export($order); // Update the success flag on the order of the results of the export. $order->setData('export_success', $exported); } }

Nothing scary here, we are just subscribing to the ‘commerce_order.place.post_transition’ event and defining a function to run in reaction to that event (onOrderPlace). Each commerce order transition defined in your order workflow automatically has a ‘pre_transition’ and ‘post_transition’ event made available, and we are subscribing to the post_transition event for the place transition. In this example, the place transition is the specific transition that happens when the order has been successfully paid for.

Inside our onOrderPlace() function, we get the order entity that is available in this event, calling the custom service that we have injected into the class, to do the exporting of the order. We then set a flag on the order using the setData method (which lets us set arbitrary data against the order) with the result of the order export from our custom service.

Of course, nothing is stopping you from having code inside of this onOrderPlace() function that does the actual exporting but we usually like to separate the logic into its own service class. This separation approach means that we can then easily call the order exporting service in other places that we might want it, such as a Drush command.

We’ll also need to let Drupal know about our new event subscriber so will need to add an entry into our module’s services.yml file, e.g.

services: example_order_exporter.order_export_subscriber: class: Drupal\example_order_exporter\EventSubscriber\OrderExporterSubscriber arguments: ['@example_order_exporter.order_exporter'] tags: - { name: event_subscriber }

In this example, we have also specified our custom order exporter service as an argument to our order subscriber (that would also have a definition in this .yml file). If you have decided to include all of the order export logic directly inside the onOrderPlace() function (or aren’t using a custom service to do such a thing) then you can omit this from the arguments to the subscriber and from the __construct() method of the subscriber in the OrderExporterSubscriber.php file.

Step 2 - The hook_commerce_order_update() implementation

The second part of the work here is to have a hook_commerce_order_update implementation inside of our custom module that will handle checking the order data that we set previously in our subscriber, and then apply the appropriate transition if successful.

It’s important that we do this here in the hook implementation! If we try to apply the transition directly inside of the onOrderPlace function from our event subscriber, then this would start the transitioning process for our new transition before the other transition has fully finished. This means that the original transition wouldn’t have necessarily been completed and any functionality driven from the transition we just applied would run, and then the original state transition that we subscribed to would try and finish off afterwards.

Aside from being logically incorrect, this leads to weird inconsistencies in the order log where you end up with something like this, e.g.

"Order state was moved from Draft to Exported" "Order state was moved from Exported to Exported"

Instead of what it should be:

"Order state was moved from Draft to Placed" "Order state was moved from Placed to Exported"

Here’s the sample code that would need to go into the .module file of the example_order_exporter module (example_order_exporter.module).

use Drupal\commerce_order\Entity\OrderInterface; /** * Implements hook_commerce_order_update(). */ function example_order_exporter_commerce_order_update(OrderInterface $order) { // Check that the current state is 'payment' (i.e. we have finished // transitioning to the payment state) and that the export_success flag is // set to TRUE on the order, which indicates our event subscriber that exports // the order has successfully run. // This hook is called *after* the transition has finished, so we can safely // apply the new transition to 'completed' here. $order_state = $order->getState(); $current_state = $order_state->getId(); if ($current_state === 'payment') { if ($order->getData('export_success') === TRUE) { $order_state_transitions = $order_state->getTransitions(); $transition_to_apply = 'completed'; // Update the state of the order by applying the transition. // If the order state transitions are empty then this order is // 'completed' and shouldn't have its state changed. if (isset($order_state_transitions[$transition_to_apply])) { $order_state->applyTransition($order_state_transitions[$transition_to_apply]); $order->save(); } } } }

We check the current state of the order is what we expect it to be - payment - and if the export_success flag we set previously is true. Only if these two conditions are true do we then try to apply the transition with the useful applyTransition method on the order state.

The $order_state has a useful method called getTransitions which returns an array of all the valid transitions for the order in its current state. This allows us to do a quick check to be sure that the ‘completed’ state (the final state of our order workflow) is present in the list of allowed transitions, before trying to apply it. If not present, this would mean this order has already been exported, and we don't try to export the order again.

We are being slightly sneaky here by calling a save on the order at this point in time, as this commerce_order_update hook is triggered during the postSave hook of the original order save. To be safe, we’ll use the (always handy) hook_module_implements_alter to ensure that our hook implementation here always runs last. This will ensure we aren’t accidentally stopping any other module’s hook_commerce_order_update implementation from running before ours.

/** * Implements hook_module_implements_alter(). */ function example_order_exporter_module_implements_alter(&$implementations, $hook) { if ($hook == 'commerce_order_update') { $group = $implementations['example_order_exporter']; unset($implementations['example_order_exporter']); $implementations['example_order_exporter'] = $group; } }

So there you have it, a nice clean way of having an automated transition run on the order without getting into any weird state transition issues caused by calling applyTransition whilst reacting to a previous transition. In this example, it’s used purely when we are exporting an order after payment has been made, but nothing is stopping you from reacting to other order transitions depending on your workflow’s needs!

LN Webworks: The 8-Step Anatomy of a Successful UX Design Process

UX Design is a cornerstone of building user-centric websites and applications. The demand for UX designers around the globe has significantly increased and the graph seems to climb every year. Why do you think that’s happening? It’s because building human-centric applications and websites is no longer an option. When UX design services combines with Drupal, a robust CMS, that makes it a deadly combination to make people choose your brand because of superior functionalities and user experience. But what is the exact UX design process? In the article, you will learn a simple (yet powerful) 8-step UX design process to implement in your business. What is a UX Design Process? A UX design process is a systematic approach to creating user-centered designs and building websites and applications that aligns with users’ needs and preferences. Here’s the cache: A UX design process that worked for one business may not work for another business. For example, the UX process for building a travel website is different from that of building a matrimonial app.

Opensource.com: Open source text editing for your website with CKEditor

Open source text editing for your website with CKEditor AnnaTomanek Mon, 04/03/2023 - 03:00

Use the power of JavaScript and CKEditor to bring rich text editing to your website.

Most applications allow users to create and add some textual content, such as a comment, a chat message, an article, a product description, or a legal document. Today, plain…

Image removed.