Drupal Planet

Talking Drupal: Talking Drupal #443 - Violinist.io

1 month 3 weeks ago

Today we are talking about Violinist.io, Managing Composer Dependencies, and automation with guest Eirik Morland. We’ll also cover Composer Patches as our module of the week.

For show notes visit: www.talkingDrupal.com/443 Topics

  • What is Violinist.io
  • How does it work
  • How much technical knowledge do you need
  • Is this a security risk
  • How much does it cost
  • Patron question: Peter: Difference between violinist and dependabot
  • What are the major differences in plans
  • Who is the ideal user
  • Can you self host
  • Can this help with Drupal 11 readiness
  • Complementary tools
  • Notable users
  • Why did you start this
  • What is it like using Drupal for a SAAS
  • Is it open source
  • Pros and cons of open source for a SAAS
  • How can the community support
  • What is on the roadmap

Resources

Guests

    Eirik Morland - violinist.io eiriksm

Hosts

Nic Laflin - nLighteneddevelopment.com nicxvan Martin Anderson-Clutz - mandclu.com mandclu Anna Mykhailova - kalamuna.com amykhailova

 

MOTW Correspondent

Martin Anderson-Clutz - mandclu

  • Brief description:
    • Have you ever wanted a simple way to manage patches to Drupal core and your contrib projects? There’s a composer plugin for that
  • Module name/project name:
    • https://github.com/cweagans/composer-patches
    • Composer Patches
  • Brief history
    • How old:created in Apr 2015 by Cameron Weagans
    • Versions available: 1.7.3 and 2.0.0-beta2
  • Maintainership
  • Actively maintained, beta2 release was a little over a month ago
    • Test coverage
    • Has a documentation site, as well as a COMMANDS markdown file in the repo to help you get started
    • Number of open issues: 10, 2 of which are bugs
  • Usage stats:
    • It’s been installed over 42 million times and it’s approaching 43 thousand installs per day, according to a recent blog post
  • Module features and usage
    • Using the plugin is simple, you require cweagans/composer-patches the same way you would a Drupal contrib project. The important difference is that composer will ask you if you trust composer-patches to make changes to your codebase. Once you grant that, the plugin is ready to start applying patches
    • You can specify what patches you want applied by adding a patches section to the extra section of your project’s composer.json file, or by adding a patches.json file
    • Each patch can be specified using a URL or a path relative to the JSON file
    • In theory it’s possible to have composer patches pulled directly from the diff in a merge request, but this is a significant security risk and should always be avoided
    • The first beta release for the 2.0 branch actually dropped support for dependency patch resolution, noting that it had become the source of most support requests. In the end the community made it clear that they would resist upgrading without this capability, so the most recent beta2 release adds it back in.
  •     Finally, on his website cweagans.net Cameron mentions that he’s currently looking for full-time employment. So if your organization relies heavily on composer in general or composer-patches specifically, consider reaching out to him

Evolving Web: What You Missed at DrupalCamp Florida 2024

1 month 3 weeks ago

The story of how I came to present at Drupal Camp Florida 2024 began in the previous year, with what someone called my “Dharizza World Tour”! I attended Drupal events in six cities throughout 2023, and ended up being invited to several more as a result. 

 

At DrupalCon Lille in October 2023, I presented a session on how to improve the Layout Builder user experience. In the audience was Michael Herchel, a member of the Drupal Association Board of Directors and lead developer of Olivero. He and Amy June Hineline (a Drupal core mentor and A11yTalks organizer) invited me to bring my Layout Builder session to the next Florida DrupalCamp. 

 

That camp was last week, and the official start to Dharizza World Tour 2024! In this blog post, I’ll catch you up on the talks I attended as well as some fun experiences from the camp (featuring rockets and fake animals, oddly!). 

Friday, February 23 Presenting to a big crowd (and one unlikely guest)

The DrupalCamp kicked off at Florida Technical College with several training sessions, including one from Lisa Ridley on how to make designer-developer collaboration easier. She had some excellent advice on leveraging FIGMA features and plugins for effective design implementations. 

 

I spent the morning preparing for my upcoming session while my teammates Nikolay, Jesse, Josh and Robert set up our booth. That afternoon I presented to a packed room at Florida Technical College—including a skeleton at the back of the class! Luckily, the skeleton was the only attendee who wasn’t lively.

 

Everyone shared notes about how we’re using Layout Builder. We discussed its pros, cons, and alternatives. We also talked about how to configure modules to improve the user experience, including Layout Builder Browser and Layout Builder Restrictions. And we tried out Layout Builder operation links, save and edit, instant preview, and Gin. By the end of the session we focused on developing Layout Plugins, either with only updates to *.layouts.yml file or by creating classes for them. It was a great time!

 

With DrupalCamp wrapped up for the day, I joined my teammates at the unofficial after-party, which went from Bounce House to Lazy Moon and back to Bounce House again. We had a blast meeting new friends and seeing familiar faces. The night was made particularly special thanks to a huge, yellow, almost-full moon. We even found out there was going to be a rocket launch on Saturday.  

 

The night ended and we arrived at the house we were staying at—only to be greeted by an enormous taxidermy deer on the wall! I’m not sure if it was real, but it was definitely creepy. After the initial surprise wore off, we named him Luke and began to treat him as one of us. He even featured in our plans and goodbyes!

 

"Luke the Deer" was an unexpected but interesting addition to our crew!
Saturday, February 23 Lessons about talent and opportunity

On Saturday we arrived early for a jam-packed day that kicked off with the Opening Session led by the camp’s organizers, Mike Herchel, Amy June Hineline and Adam Varn.

 

Next, I listened to Matt Glaman present on the opportunities of open source. He told the story of how he went from transporting beer to becoming a top Drupal contributor! Did you know he created Retrofit? It’s a project that you can use to run your Drupal 7 code in Drupal 10 while you fill the gaps and actually get them ported. (Matt ran a session on Retrofit the next day, where he explained how to contribute to the project). 

 

One of my favourite moments was when Matt said: “Talent is equally distributed, but opportunity is not.” I think that’s a powerful message. There are lots of talented people out there that haven’t yet had the opportunity to shine. But open source can help with that: it empowers people to develop and show off their skills, helping them advance both their career and the open web. Matt highlighted the importance of lifting people up through mentorship and friendship.

 

Meanwhile, Rod Martin presented a session on Advanced Layout Builder for the Ambitious Site Builder. He created a starter site that anyone can spin up and test out to help them develop their Layout Builder skills. 

 

At 11am it was time for our own Jesse Dyck to present ‘What Non-Developers Should Know About Content Migration’. Jesse spoke to a full room on how to develop a migration plan, common migration challenges, how to ask your team the right questions, and how to anticipate and fix issues. 

 

At the same time, Matthew Ramir gave insight into his personal story in ‘Code, Cerebral Palsy, and Compassion: My Journey into Tech’. He spoke about his history, struggles, and triumphs, and even shared some of his poetry! We learned about the importance of opportunities, diversity, acceptance and self-acceptance. It was a truly inspiring talk. 

 

After lunch at Gringos Locos (our DrupalCamp Florida tradition), it was time for our own Nikolay Volodin to share the case study of a custom CKEditor 5 plugin that he developed at Evolving Web. He dissected the plugin for the audience to identify its parts and explain how they behave and interact. 

 

Meanwhile, Aubrey Sambor, Florida Drupal Camp Featured Speaker, took to the auditorium stage to talk about Color in CSS—including using new spaces, functions and techniques to make your site shine. Ana Laura Coto and Carlos Ospina led a session about Building the IXP Fellowship, a new initiative for onboarding inexperienced developers.

 

Next, it was our Robert Ngo’s turn to present. He delivered a session to a packed room about building a component library with single directory components (SDCs). But it wasn't the usual “how to” format. Instead, he explored the strategy behind the way we structure SDCs, how to define conventions with development and design teams, how to evolve a component library, and how to test it.

 

We wrapped up the day with a few lightning talks, as well as a session from Ofer Shaal on how to quickly create web components for reuse across React, Angular, Vue, Drupal and other CMSs.

 

Evening brought the camp’s official after party. It was fantastic to spend more time with our Drupal friends, both new and old. Sadly the rocket launch was delayed. We were also hoping to see some ‘gators, but all we found was a huge fake one with a sign that said “Swampies”! We decided that was good enough—and certainly a less dangerous photo opportunity.

 

Me enjoying the start of "Dharizza World Tour 2024"!
Sunday, February 24 Wrapping up the weekend with a different kind of launch

Time passes fast when you’re having fun and that’s how Sunday found us. We packed our luggage and waved goodbye to Luke the taxidermy deer, before heading back to Florida Technical College for a last day of sessions and contributions events. 

 

First up were Matt Glaman and Darren Oh from the Retrofit project, who troubleshooted and live coded to show how to run D7 code in D10. At the same time, Kyle Einecker cleared up the meaning of coupled and decoupled Drupal. 

 

A contrib learning extravaganza happened at 11am in the auditorium, where Amy June and Mike Anello showed people how to contribute through code, documentation, project managing, and everything Drupal related. Unfortunately, I wasn’t able to stay for the afternoon due to allergies. But my team members enjoyed the contrib afternoon—and even got to witness the rocket launch!

 

Thanks to everyone who made DrupalCamp 2024 possible. If you didn’t make it to the camp, I hope this article gives you some insight and inspires you to attend the next one. The “Swampies” and I will see you there!

 

Looking for more events that focus on open source innovation? Check out the EvolveDrupal summit

 

+ more awesome articles by Evolving Web

The Drop Times: Growth: Embracing Success Through Progress

1 month 3 weeks ago
Explore the journey of growth with Drupal: Uncover the essence of progress and its transformative benefits.

Dear Subscribers, 

Sometimes, growth hinges on the effort we invest—the sweat equity makes all the difference. It's an ongoing journey that reminds us of our potential for continual advancement. Growth isn't just a milestone; it's a guiding force steering us toward realizing there's always more to achieve.

Let's take a moment to appreciate Drupal's remarkable evolution in this spirit of perpetual progress. With an ever-expanding community and a track record of powering some of the world's most influential websites, Drupal continues to ascend in popularity and capability. Its open-source ethos fosters collaboration, driving collective growth and empowerment for all involved.

As Drupal flourishes, so do its users. Its robust features and scalability ensure that businesses and organizations can adapt and thrive in today's dynamic environment. Drupal's unwavering commitment to security and its ever-growing community sets it apart from other CMS platforms. The truth that cannot be denied is the level of security it provides, which remains unmatched in the industry. Moreover, Drupal excels in providing customer-centric and personalized user experiences, empowering organizations to tailor their digital presence to the unique needs of their audience.

However, what truly propels Drupal's growth to unprecedented levels is its community-driven ethos. With a vast network of developers, designers, and enthusiasts collaborating and contributing tirelessly, Drupal evolves rapidly, staying ahead of the curve in innovation and adaptability. This collective effort fosters a culture of continuous improvement, ensuring that Drupal remains at the forefront of technological advancements.

Now, Let's take a moment to revisit the highlights from last week's coverage at The Drop Times.

I had the opportunity to connect with Amber Matz, a key contributor, who shared insights into the Documentation and Help initiative. Amber provided valuable insights into the initiative's goals and the recent updates to Drupal.org's documentation page, emphasizing the community's dedication to improving user experience. 

Elma John presented an exciting feature on MidCamp happening in Chicago. She conversed with Norah Medlin and Avi Schwab, the lead organizers of MidCamp 2024. Through their insights, we learned more about the event's agenda and the collaborative opportunities it offers for the Drupal community.

Alka Elizabeth shared insider views of DrupalSouth Sydney 2024, giving us a glimpse into key technical updates and diversity initiatives. Her article offered valuable perspectives on the enriching experiences shared at Drupal South, which took place on March 20-22. She also shared the list of winners of The Drupal Splash Awards 2024 in Australia and New Zealand across all categories, revealed during the DrupalSouth Sydney 2024 event held at Sydney Masonic Centre. 

Explore the evolving dynamics of Drupal's page-building features with André Angelantoni's latest series on The Drop Times. In part 1 of the series, André explores Paragraph-Based Solutions, shedding light on the progression of Drupal's page layout options. Stay tuned for insightful discussions on enhancing page-building capabilities in Drupal. The second part of the series is scheduled to be published today. 

The Drupal Pune Group announced its first meetup of 2024, scheduled for March 30 from 10:00 AM to 1:00 PM IST at Bookavibe - Book Cafe and Co-working space on Fergusson College Road, Pune. Following the success of the first in-person Drupal Camp in India last year, the group is gathering once again to discuss plans for future Drupal events and collaborations. Registration has officially opened for EvolveDrupal Atlanta, an event that brings together developers, designers, strategists, marketers, managers, and more for learning, networking, and inspiration. Don't miss this opportunity to be part of a vibrant Drupal community event.

DrupalCamp Ghent has issued a call for sponsors for its upcoming event. Sponsors' support is crucial in ensuring the camp's success, enabling organizers to provide valuable experiences to attendees. Consider becoming a sponsor to support the Drupal community and showcase your organization's commitment to Drupal. Antonio José Fuster, Community Manager - Technical Communication and Innovation at the City of Benidorm in Spain, revealed the dates for the upcoming DrupalCamp Spain 2024. The event is scheduled for October 25 and 26, with October 24 earmarked as Business Day. Stay tuned for more details about this exciting event!

Mark your calendars for June 12 as Drupaljam 2024 opens at the Fabrique in Utrecht. This gathering promises an engaging experience for Europe's Drupal community. Take advantage of limited-time early bird ticket offers available until March 31. Secure your spot now for this anticipated event! Don't miss DrupalCamp Colorado 2024, scheduled for June 25 and 26. This event allows attendees to foster new community ties and engage in thought-provoking conversations. 

Excitement buzzed at DrupalSouth Sydney 2024 when Tim Doyle, CEO of the Drupal Association, made a surprise announcement during his closing remarks. DrupalCon Asia 2024 is set to happen in Singapore, likely from December 4-6, 2024, sparking enthusiasm among the global Drupal community. DrupalSouth Sydney 2024 featured captivating keynote sessions, including one by Dries Buytaert, the pioneer of Drupal. Buytaert delivered an inaugural keynote on the topic "The Drupal Project Update," providing valuable insights into the future direction of Drupal.

After a notable tenure as Program Manager and Drupal Innovation Coordinator, Alejandro Moreno López bids farewell to the Drupal Association. In his heartfelt LinkedIn post, Alejandro reflects on his journey with the organization and praises its dedication to advancing open-source technology. 

Drupal is witnessing a new wave of discussions and proposals, particularly around marketing and features. Notable figure Andrew Kucharski, CEO of Promet Source, ignited conversation with a thought-provoking post on LinkedIn. Kucharski addressed the need for a more accessible and polished list of Drupal features and benefits for a broader audience. Click here to get a detailed insight. 

We understand that there are additional stories worth exploring. However, due to current constraints in selection, we must temporarily halt further exploration.

To get timely updates, follow us on LinkedIn, Twitter and Facebook. Also, join us on Drupal Slack at #thedroptimes.

Thank you,

Sincerely
Kazima Abbas
Sub-editor, TheDropTimes.

Drupal StackExchange

Check if form already failed validation

1 month 3 weeks ago

I added a validation hook to a node creation form.

For my project, i need this validation only ONE time: basically i just check if a value already exists in the DB and i notify it to the user. If the user still submits the form, i must add it anyway.

i would like to do something like that:

if (form_did_not_fail_validation_before) { $form['#validate'][] = 'my_module_validation_hook'; }

in my hook_form_alter, so that validation hook is only called the first time.

I can't find a way to check if the form already failed validation, any ideas?

gbalduzzi

How would I by default have a dropdown block expanded instead of collapsed?

1 month 3 weeks ago

I want to be able by default have a dropdown block expanded instead of the current default which is to show just the link and if the user clicks on it then it would expand. Below is some code related to collapsing and expanding dropdown blocks which is contained within a .js file within the default theme (sites/all/themes/fusion/mapsindeed/js). How would I, by default, have a dropdown block expanded instead of collapsed?

//ability to expand and collapse dropdown blocks Drupal.behaviors.mapsindeedDropdownBlock = function (context) { $('.mapsindeed-dropdown-block .content').hide(); $('.mapsindeed-dropdown-block h2.block-title').bind('click', function(){ $(this).siblings('.content').slideToggle('slow', function() { }); $(this).parents('.mapsindeed-dropdown-block').toggleClass('expanded'); }); }
John Mitchell

Is a content type or profile a better choice?

1 month 3 weeks ago

I am working on a new site where I want to show information for art galleries, artists, museums, public art installations and art education.

I understand both the content type and profile differences but can't decide which is better in the long run. I know the artists will need a profile and I would like to give the rest of the "types" the ability to edit their own content if they desire.

I have done a lot of research and can't seem to find an answer on how to link a content type entry with a user profile and am leaning toward profiles for everybody. However, this has drawbacks because of need for authentication info (which I don't know) as I create the profile.

Am I missing a magic module or some other clue?

Pat U.

Multiple Different AJAX Enabled Forms on the Same Page

1 month 3 weeks ago

I currently have a form that is being loaded by AJAX and is working perfectly. I now need to add a second form (Add Single Stat) to the same page via AJAX as well. The Add Single Stat form is being loaded to the page perfectly but when the AJAX callback is fired for the db_selection select list, I get "An AJAX HTTP error occurred. HTTP Result Code: 200" AJAX error. I'm really not sure where this error being caused from and would like to find a fix to this issue.

The Add Single Stat Form is being built with the following code:

public function buildForm(array $form, FormStateInterface $form_state) { $form['db_selection'] = array( '#title' => t('Data Location'), '#title_display' => 'invisible', '#type' => 'select', '#options' => array("" => "Select", "enrollmentdata" => "Student Enrollment Data", "summerenrollmentdata" => "Summer Enrollment Data"), '#prefix' => '<div id="db_selection" class="AddQueryFormElement">', '#suffix' => '</div>', '#ajax' => array( 'callback' => 'Drupal\dashboard\Controller\DashboardController::SingleStatOnDBSelection', 'effect' => 'fade', 'event' => 'change', 'progress' => array( 'type' => NULL, 'message' => NULL, ), ), ); $form['term_selection'] = array( '#title' => t('Select Term'), '#title_display' => 'invisible', '#type' => 'select', '#prefix' => '<div id="term_selection">', '#suffix' => '</div>' ); $form['ss_id'] = array( '#title' => t('Single Stat ID'), '#type' => 'hidden', '#prefix' => '<div id="ss_id" class="AddQueryFormElement">', '#suffix' => '</div>', ); return $form; }

I am then loading The Add Single Stat Form to the page via this ajax callback:

public static function AddSingleStatToPanel(array &$form, FormStateInterface $form_state){ $ajax_response = new AjaxResponse(); //Generate a Unique ID for the single stat $SingleStatID = self::GenerateRandomID(15, 'single_stat_info', 'single_stat_id'); //Add The "Add Single Stat" To the correct DIV $AddSingleStat = \Drupal::formBuilder()->getForm('Drupal\dashboard\Form\AddSingleStat'); self::SetUniqueAddSingleStatFormDivIDs($AddSingleStat, $SingleStatID, TRUE); $ajax_response->addCommand(new AppendCommand('#AddSingleStatForm_'.$SingleStatID, $AddSingleStat)); return $ajax_response; }

I handle updating the form to contain unique element id values as well as unique ids for the divs surrounding the form elements in this function:

private function SetUniqueAddSingleStatFormDivIDs(&$FormRenderArray, $SingleStatID, $HideFields = TRUE){ $FormFields = array('term_selection', 'ss_id'); $FormRenderArray['db_selection']['#prefix'] = '<div id="db_selection_'.$SingleStatID.'" class="AddQueryFormElement">'; foreach($FormFields as $FormField){ //Set Each DIV's ID to the Form Field ID_SingleStatID if($HideFields || $FormField == 'chart_type'){ $FormRenderArray[$FormField]['#prefix'] = '<div id="'.$FormField.'_'.$SingleStatID.'" class="hide" style="display:none" >'; } else { $FormRenderArray[$FormField]['#prefix'] = '<div id="'.$FormField.'_'.$SingleStatID.'" class="AddQueryFormElement">'; } } $FormRenderArray['ss_id']['#value'] = $SingleStatID; $FormRenderArray['#attributes'] = array('id' => array('ss_'.$SingleStatID)); }

Inside of the dashboard controller I have the AJAX callback that I would like to be called when the user changes an option in the db_selection select list.I have reduced the code here to just a simple JS alert.

public static function SingleStatOnDBSelection(array &$form, FormStateInterface $form_state){ $ajax_response = new AjaxResponse(); $ajax_response->addCommand(new AlertCommand('It Works!')); return $ajax_response; }

Update: I have done a little more debugging and the only way I can make this form work correctly is if I pass the form's render array to twig file and load it that way. The form doesn't seem work at when using AJAX to loads the form's HTML.

iWig

Add metatags import to migration

1 month 3 weeks ago

I have made a migration module to import the full content from a legacy Drupal 6 site to my new Drupal 7 site, using the migrate d2d module. Everything works fine, but I have just discovered that there are many custom meta tags added manually for both nodes and taxonomy in the legacy site (using the Metatags module). The taxonomy meta tags I can deal with manually, but I really would need to figure out how to add the mapping for metatags in my node migration classes. Do I add code in my general migration class in node.inc (that extends DrupalNode6Migration)?

Do I use prepareRow() to fetch info from the database and add this to a mapping with a default value in the new site? As far as I can see there are no fields in the legacy site that holds the metatags (I need title, keywords and description).

If anyone knows how to do this, please help.

TBJ

How can I check if the redis module is enabled in settings.php?

1 month 3 weeks ago

I've read How can I check if a module is enabled? and How can we use \Drupal class inside Settings.php and came to the conclusion that I cannot use the module_handler service in settings.php.

How can I check if a module -- in this case the redis module -- is enabled in settings.php?

Context

I am using docker for a Drupal 9.4 installation. When I initialize a new container from the image, and I install Drupal (initialize a new database), the redis module isn't initially activated, although present.

This means I cannot initially specify $settings['cache']['default'] = 'cache.backend.redis'; in settings.php (it will make the system crash).

I would have like to do

$moduleHandler = \Drupal::service('module_handler'); if ($moduleHandler->moduleExists('redis')) { $settings['cache']['default'] = 'cache.backend.redis'; }

Of course this doesn't work and I understand why. But I would like to avoid going into my container to edit settings.php after activating the redis module every time I start a new container.

leducvin