#! code: Drupal 10: Creating Context Aware Plugins

In previous articles I have written about injecting context into context aware plugins and creating custom context providers and wanted to complete the series by writing about creating context aware custom plugins.

The context system in Drupal is a powerful way of injecting dynamic data into plugins without writing code to add that data directly to the plugin itself. Instead of adding custom code to find the current user or the node from the route of the page you can inject the context into the plugin using the context system and add code to make use of that data. Although most commonly used in blocks it can be found in a couple of other plugin types in Drupal core, like the condition plugin for example.

In this article I will go through how to create a context aware plugin, including how to create custom plugins and how to allow that plugin to understand the context_definitions annotation. Once the custom plugin is complete we will render it using a Drupal controller action to prove that the context works correctly.

Let's start by creating a custom plugin, we'll call this plugin ContextThing and it will be used to print out the context passed to it. The first step in creating custom plugins is to create an Annotation class.

Plugin Annotation Class

Annotations are special kinds of comments that have a number of functions in Drupal, but in this case we are using them to inform Drupal that a particular class is plugin.

As an example of annotations in action we can look at defining custom Blocks. To define a block plugin you would start the class annotation with @Block and then add the fields you need to the annotation definition. This would look something like this.

Read more

The Drop Times: We Will Tell You Anything That We Are Legally Able to Tell You; Jonathan Daggerhart | FLDC

“Happiness is not the right metric by which to measure someone’s work life; “low-stress” might be better" Says Jonathan Daggerhart in his interview with TDT. Drupal Camp Florida is here, and as TDT is an in-kind sponsor we took this opportunity to speak to the FLDC session speakers.

Drupal Association blog: Volunteering at DrupalCon: Benefits and Highlights

DrupalCons are for everyone who loves to build and grow with Drupal. These events bring together community leaders, developers, designers, content creators, and users to share their knowledge, skills, and experiences. Whether you're a seasoned pro or just starting out, DrupalCons are a perfect platform to expand your horizons, network with like-minded individuals, and have fun in the process!

And what could be a more effective way to interact with as many people as possible than to volunteer? The highly anticipated DrupalCon Pittsburgh 2023 is just around the corner, and we’re looking for event volunteers to make it a resounding success!

Why volunteer?

For starters, you get a free ticket when you volunteer for a minimum of 8 hours! If that doesn’t cut it for you, discover more reasons to volunteer and be a part of this exciting event:

  • Scientific effects of giving - When you’re volunteering for an event you care about, you are giving your time and a part of yourself to it. This has multiple psychological, social, and physiological benefits for you. Studies show that giving can trigger the release of feel-good chemicals like oxytocin, dopamine, and serotonin, resulting in a feeling of happiness, satisfaction and well-being.
  • Personal development - After contributing to DrupalCon for the three years in a row, I am able to personally attest to my growth and the impact it has had on me. Volunteering helps you gain new skills, knowledge and experience. This can boost your self-confidence and enhance your personal growth.
  • Building connections - This is one of my favorite reasons to contribute. Volunteering gives you a chance to interact with people from diverse backgrounds who have a very different skillset than yours. Learning opportunities are immense when you collaboratively work as a team.
  • Community involvement - If you’re passionate about Drupal, you should love giving back to the community that helps build Drupal. It is simply the right thing to do if you’re using Drupal in any way. Being a part of an event as huge as DrupalCon is a great way to contribute and get involved with the community.
  • Career advancement - Gain practical experience and demonstrate your commitment to the industry when you volunteer for DrupalCon. You are exhibiting your willingness to take the initiative and that’s a quality all employers are looking out for. Additionally, when you earn credits for your contributions, it benefits both you and your employer.

Open positions and How you can help

Out of the many opportunities to volunteer at DrupalCon Pittsburgh, we now have 3 open positions remaining. The Speaker Review committee, Marketing & outreach committee, Local Ambassador, Summit Program committees positions have been filled. Check out more details here.

Translation Assistant

DrupalCons are for everyone from anywhere! We strive to provide a fantastic experience for all DrupalCon attendees. We are seeking volunteers to make English second language attendees feel comfortable and at home. Do you speak a language other than English and want to help others have a better DrupalCon experience? This could be a perfect opportunity for you!

Time commitment: 15-20 hours till June 2023 (including 4 hours on-site at DrupalCon).

Scholarship Mentor

This is a great opportunity for you to pay it forward and support the next generation of leaders. As a Scholarship mentor, you will guide scholarship recipients through their DrupalCon journey. This being their first time at an event as big as DrupalCon, you will help them understand expectations like the Code of Conduct and also suggest programs they should attend. You will help them build better connections with members of the community who share similar interests. So basically, for them, you will be a friendly face in an unfamiliar environment.

Time commitment: 5-10 hours in May and June (including on-site at DrupalCon)

Logistics Contributor

Logistics Contributors are the event superheroes, saving the day with their high-octane energy and smooth communication style! You will work with the event staff to manage the registration desk, warmly greet attendees, guide them to their destinations, and help with set-up/tear-down tasks. To ensure the smooth running of the event, you will also assist the Conference staff as needed.

Time commitment: 4-8 hours of on-site time at DrupalCon

Evolving Web: Open Source vs Proprietary Software: 3 Common Myths, Busted

Image removed.

There are two choices when it comes to building a website: an open source platform like Drupal or WordPress, or a proprietary platform overseen by a company like Adobe or Microsoft. How to know which is best for your website? 

Things to consider:

  • How much user support will I get?
  • Which is better for security?
  • Is the cost within budget?

For organizations with limited budgets, the choice is either an open source site or something less flexible like Wix or Squarespace – the cost attached to a proprietary platform might be out of reach. However, for a large enterprise organization, both approaches have their pros and cons that are worth addressing.

Proprietary platforms like Sitecore, Microsoft SharePoint, or Adobe Experience Manager are attractive to many large organizations for several reasons. In addition to promising great platforms customized to the client’s business needs, proprietary arrangements typically offer full hosting plans. The company behind the CMS handles all updates, upgrades, security issues, and bugs – often 24/7.

While proprietary comes with some sticker shock, there is a sense of justification behind it: at least you get what you pay for.

It’s worth noting, though, that many of the world’s biggest corporate brands use Drupal as their CMS of choice. These include General Electric, Tesla, IBM, Twitter, Paramount Global and United Airlines. The Government of Australia operates on Drupal, as does the Government of Ontario, the Canadian Security Intelligence Service (CSIS), several US state governments and countless other government agencies around the world.

So, why do organizations that have large budgets for web development opt for an open source platform, despite the advantages touted by proprietary providers? 

The answers are numerous, ranging from a need for financial accountability to the supportive nature of the Drupal community. These factors more than make up for any potential shortcomings of the open source model.

Let’s run through some popular myths around proprietary and open source platforms that continue to influence decision making.

Myth #1: “Proprietary Platforms Provide Better User Support”

One of the main selling points of proprietary platforms is that its vendors promise 24/7 client support should anything go wrong with the site, or if you need anything customized. This 24/7 support comes at a cost. For institutions concerned about sudden emergencies, this is obviously an appealing offering that for many justifies the price tag.

What proprietary vendors won’t tell you, however, is that open source platforms like Drupal provide much of the same service (typically in tandem with an agency and an infrastructure partner like Acquia or Pantheon) at no cost through their networks of volunteers and sponsored contributors. 

Drupal, for example, is supported by a global community of hundreds of thousands of contributors who work collaboratively to address technical issues and improve the platform.

In the Drupal world, when you find a bug and create a report within the community, the response–while not necessarily instantaneous–is typically fast. While mission-critical sites like government platforms will need to pay somebody to be available for 24/7 support, this broader community support is of enormous benefit to all Drupal users.

Proprietary platforms do have counterparts to this type of community, but they’re oftentimes much smaller. Sitecore, for example, advertises that it has a community of 20,000 developers – a drop in the bucket compared to the scope of the Drupal developer community. 

Myth #2: “Proprietary Is More Secure Than Open Source”

This is a stubborn myth - understandably. Open source code, by its nature, is publicly available to anyone, including individuals with malicious intent. In contrast, proprietary platforms keep their codebases under lock and key. The for-profit nature of proprietary vendors, we’re told, gives them a greater (financial) incentive to track down and neutralize bad actors.

The unpopular truth is that proprietary platforms are every bit as vulnerable to attacks as their open source counterparts – if not more so. 

For one thing, most security breaches don’t come from hackers scouring source code for weak spots, but from avoidable human lapses such as failures to follow security guidelines, improper software setup, use of easy passwords, lack of data validation processes or absence of data encryption techniques. These lapses are no less likely to occur on a proprietary platform than they are on an open source one.

Paradoxically, the open source nature of platforms like Drupal is actually more of a help than a liability when it comes to cybersecurity. Open source code means that anyone with the know-how can search for and identify vulnerabilities. And with an army of over a million developers contributing behind the scenes, Drupal can rightly claim to be one of the most secure platforms on the planet. Proprietary vendors, by contrast, are limited in this capacity by their cybersecurity staffing numbers.

Myth #3: “Proprietary Costs More, So You Get More Value” 

It’s widely believed that when you opt for a less expensive product–in this case, an open source website–you’re either settling for a “less-good” quality product or setting yourself up for additional costs down the road in the form of upgrades and modifications. Proprietary websites, we’re told, may cost more at the outset, but at least you know you’re getting something of real quality and the costs are predictable.

In truth, there is no difference in quality between open source and proprietary websites. It all depends on the quality of workmanship that goes into building the sites. 

And while any website project is vulnerable to budget overruns, proprietary platforms are actually more prone to them than open source ones.

When you opt for a proprietary platform, you automatically commit to paying for a licence. This may be a one-time cost or a recurring subscription fee. In many cases, proprietary providers charge on a “per-seat” basis, meaning that the larger your team gets, the more expensive maintaining your website becomes. An open source site, by contrast, costs nothing beyond what you spend on design, and is in fact much more predictable from a cost standpoint.

This is of particular importance to governments, whose website development and renewal costs are publicly available and subject to intense media scrutiny. The Government of Canada faced negative press after it hired Adobe to restructure a vast swath of federal websites under the Canada.ca URL. A project originally valued at $1.54 million in 2015 had by the following year ballooned to $9.2 million. While details were scant, some of this budget overrun was attributed to costs due to additional staffing requirements. Cue impending doom music.

Websites built on open source platforms like Drupal aren’t cheap to develop, but the costs are almost always more predictable. And when it’s the taxpayers who are footing the bill, this is a major advantage.

Bonus: Open Source = Wider Talent Base

If you’re a large government organization with complex web needs, chances are you’ll be looking to hire in-house developers. From this standpoint, it makes much more sense to opt for an open source web platform in terms of available talent. The magnitude of the Drupal community relative to, say, Sitecore, means that your LinkedIn search is far more likely to turn up Drupal specialists in your area than Sitecore experts.

Similar disparities exist when it comes to providing your staff with training. Drupal training is widely available and affordable. Hint: we offer customized training. Becoming a licensed developer for something like Adobe Experience Manager, by contrast, is a much more complex and expensive undertaking.

Why Drupal Specifically?

We’ve touted Drupal extensively throughout this post, as Evolving web is the home of many Drupal trainers, developers and experts. However, it’s far from the only open source CMS option out there. WordPress remains the world’s most popular CMS platform, being used by some 43% of the world’s websites. 

Drupal does, however, stand out from the pack in a number of important ways. The Drupal platform simply has more features and is a lot more supportive of customization than most of its open source competitors. This is perhaps less of a big deal if you’re a small business or organization with a narrow area of focus, but government websites are generally complex, high-traffic undertakings responsible for disseminating a wide range of content to a diverse array of audiences.

Other Cool Government Sites Are Using It

Evolving Web recently redesigned the official website for the City of Hamilton. As the main online hub for Canada’s ninth largest municipal area, serving some 800,000 people, the City of Hamilton website caters to a wide range of audiences, from residents and local business people to tourists and foreign investors. Its services run the gamut, enabling residents to plan public transit use, pay property taxes, find employment, apply for a marriage licence and get information on recreational activities, among many other options.

The City of Hamilton site exemplifies many of Drupal’s strengths. Like many government websites, it encompasses vast swaths of data and resources and is subject to considerable surges in traffic, both of which Drupal is well equipped to handle. The site revamp also involved corralling various third-party services (including the recreation sign-up and council meeting scheduler) and a half-dozen websites that existed outside of Drupal, which required creative solutions of the sort that the Drupal community excels as developing.

Drupal Upholds Accessibility Standards

A further advantage of Drupal for government websites is that its publishing platform, along with all of its other features and services, is designed to be fully accessible in accordance with WCAG standards. Drupal’s default settings ensure accurate interpretation of text by screen readers, provide accessible colour contrast and intensity recommendations, generate pictures and forms that are accessible and incorporate skip navigation in its core themes.

You’ll Be In Good Company

All this attests to the strengths of the open source model–and of Drupal in particular–underpinned as it is by an army of over a million contributors. Thanks to this, the platform is in a constant state of improvement and innovation, of which every single Drupal user is a beneficiary.

Join The Club

At Evolving Web, we specialize in helping organizations harness their online presence with open source platforms like Drupal and WordPress. Let’s keep in touch! 

//-->

+ more awesome articles by Evolving Web

Nonprofit Drupal posts: February Drupal for Nonprofits Chat

Join us TOMORROW, Thursday, February 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

View notes of previous months' calls.