Drupal Planet

Wim Leers: State of JSON:API (January 2019)

8 godzin 45 minutes ago

As promised 3 months ago, Gabe, Mateu and I shipped support for revisions and file uploads today!

What happened since last month? In a nutshell:

JSON:API 2.1

JSON:API 2.1 follows two weeks after 2.0.

Work-arounds for two very common use cases are no longer necessary: decoupled UIs that are capable of previews and image uploads3.

  • File uploads work similarly to Drupal core’s file uploads in the REST module, with the exception that a simpler developer experience is available when uploading files to an entity that already exists.
  • Revision support is for now limited to retrieving the working copy of an entity using ?resourceVersion=rel:working-copy. This enables the use case we hear about the most: previewing draft Nodes. 4 Browsing all revisions is not yet possible due to missing infrastructure in Drupal core. With this, JSON:API leaps ahead of core’s REST API.

Please share your experience with using the JSON:API module!

  1. Note that usage statistics on drupal.org are an underestimation! Any site can opt out from reporting back, and composer-based installs don’t report back by default. ↩︎

  2. Which we can do thanks to the tightly managed API surface of the JSON:API module. ↩︎

  3. These were in fact the two feature requests with the highest number of followers↩︎

  4. Unfortunately only Node and Media entities are supported, since other entity types don’t have standardized revision access control. ↩︎

Lullabot: Behind the Screens with Tom Sliker

17 godzin 21 minutes ago
Tom Sliker started Broadstreet Consulting more than a decade ago, and has made Drupal a family affair. We dragged Tom out of the South Carolina swamps and into DrupalCamp Atlanta to get the scoop. How does Tom service more than 30 clients on a monthly basis with just a staff of five people? His turn-key Aegir platform, that's how! Join the conversation at https://www.lullabot.com/podcasts/drupal-voices/278-tom-sliker

OpenSense Labs: Heading towards change - Upgrading or Upcycling?

21 godzin 56 minutes ago
Heading towards change - Upgrading or Upcycling? Vasundhra Mon, 01/21/2019 - 08:55

You’ve been living in a house for a while now and you are still fond of that place. But its no longer exactly what you need, and you are dreading for a change. 

You think of rearranging and modifying a few things. Maybe paint the room walls in vibrant colors or set up brand new furniture. And voila, it feels like home once again. 

A similar situation can be analyzed with the websites also. 

Websites are redesigned to keep up with the online trends. Sometimes it is done merely because the owners learn over time that the site design is not ideal for their purpose.


Coming back to the redesigning, people face scenarios where their house gets really old and is on the verge of collapsing. These type of situations demands them to move on to the next one exactly like the way a website owner does when he/she witnesses an end of its life cycle.

So what are these things? Is there a term for it? Is it a process? and what are the methods involved in it? 

Let’s see what exactly the terms are.

Introducing Upcycling and Upgrading 

It is true that a full rebuilt of a website is time-consuming and an expensive task just like a full rebuilt of the house is. In such situations you are only left with two options - either modify it to necessary changes or hop onto a completely new site.

If you choose the option which simply involves a refreshing appearance of the site or modifications in some parts then Upcycling is the hero for you.

To reuse the existing materials and create a product of higher value or quality than the original object or materials is termed as upcycling. 

In technical terms, Upcycling is an incremental approach to relaunch an existing website that is done to keep up with online trends, or maybe because of technical debt, or the reason where you have a well-established website and you have no plans of reconstructing it as a whole.  

Another option is to bring a website to cutting edge technology that is done for optimal results and an increase in revenues and profits. In other words Upgrading. 

Comparing Upgrading and Upcycling    Upgrading Upcycling When to do it? Can be performed when you start witnessing the end of a life cycle. Can be performed at any stage of an existing project Why to do it? Because the website contains bugs and is prone to hackers. To give the website a new appearance and improve the user experience. Rate of Investment You can see your investment as quickly as possible  The ongoing maintenance and upkeep are where you start to see your investment.  Performance Performance measurement takes several months and can be achieved with the help of different metrics Can be measured with the help of conversion rate and other metrics.  How to do it? Add more content, create multiple landing pages, go mobile friendly Allow to innovate and bring newer design versions for the relaunch of the whole site. When to do it?

Upcycling

If you have low cash but have time and some creativity in your mind you can reclaim almost anything and repurpose it. In other words, any website can be repurposed or redesigned at any stage of an existing project with existing website infrastructure. 

For a well-established web system that has been operational for several years, and doesn’t want to spend time and money to do a full rebuild, upcycling is for you. This brings improvement in editorial experience, user experience, front-end etc. 

Upcycling is also adopted due to the reason of investments. Implementation of investments is quick and easy.
 

 
Upgrading 

Computers and other electronics cannot be upcycled after they have come to an end of their life cycle, they must be upgraded to keep up with the technological advancements. Similar is the case with the websites. Websites are upgraded when it lacks functionality and speed, search engine fails to detect it or when it fails to meet lasting impressions. Upgrading a website is like a do-over of your brand.

Upgrading a brand new websites kills an enormous amount of time and leaves an organization with immense cost.

The reason why it faces such issues is evident, it is started from scratch and therefore requires deep research and analytics.

Why to do it?

Upcycling

Websites owner have plenty of reasons to transform their website. It might be due to the reason where they want a fresh appearance of their website, or because of the technical debt, or simply because they want to improve their user experience. 

Upcycling is the answer for all.

Though upcycling might de-prioritize the motto of “Big Bang Launch”, it meets one primary goal which is to reduce time to market for big website improvement.

Upgrading

Is your website prone to hackers and bugs? Is it preventing website visitors to find their way to your website’s content? - then it is time for you to upgrade it. Upgrading your website includes four main factors: Design, Marketing, Usability and Time. 

Design: It is the appearance of your website that reflects the business message which you are trying to portray. The design represents the collection of things like mobile responsiveness, compatibility with the browser, image resolutions

Marketing: Once the website design is done and the content is established, it is the time to promote it. Marketing involves all the SEO updates, measurement of effectiveness and a call-to-action (A button or link that is placed on a website to drive prospective customers to become leads by completing action on your landing page)

Usability: It is the term which describes the ease with which a particular website or a project is used. Usability helps in decreasing bounce rates and contributes to the performance. 

Time: A fresh website is a perfect way to save the admin’s time. This directly affects the customer service also. 

Rate Of Investment (ROI)

Upcycling 

ROI or rate of investment in Upcycling depends on the two factors sequentially:

  • The cost and
  • The results of a website. 

Cost is termed as the price of the website, which varies widely depending upon the budget and funds of the organization. Generally, the price of the website relates to the total time taken to create it. Factors such as project management, design, programming, team, content, CMS etc determines the cost of a website. 

Whereas the result also contributes to being an important factor in the whole journey of ROI. The website ROI may literally be negative if the site doesn’t produce the desired results which in return gives a loss in the cost. Factors affecting ROI are the cost of creating and maintaining the website, traffic, conversion rate, website lifespan etc.

When both these things, cost, and the result going overboard (and done right) it can generate so much demand that you would witness a steep increase in the website conversions. The ongoing maintenance and upkeep are where you would start to see your investment. 

Upgrading

Once you have taken a leap and invested in the reconstruction of your organization’s website it’s time to begin the calculation concerning ROI. While it is difficult to predict the precise ROI for a brand new website, it would definitely result in a host of benefits.

Benefits that might include an uptick in search engine ranking and a steady generation in the interest of potential buyers and customers. Though there are no dry methods to measure the ROI, there are different ways to track the success and determine whether you are meeting your goals or not.

Tracking the web activities, Monitoring search engines and calculating cost are some of the unique ways to do it. 
 

Performance 

Upcycling

Website owners who walk down the path of redesigning a website would agree with the fact that there’s a single most important metric that determines the success of a website: i.e Conversion Rate 

A conversion rate is the percentage of visitors to a website that completes the desired goal for the total number of visitors.

A high conversion rate is an indication of successful marketing and web design. It means people want what you are offering and that they are able to understand it. The whole point of redesigning a website is to improve the performance of it. 

Apart from conversion rate, there are certain other metrics which when optimized well would lead to better conversions and performance of your site. Metrics like:

  • Number of session per user
  • Pages per session 
  • Less bounce rate 
  • Per clicks around your website 

Upgrading

Let's assume that your organization has a great unique idea, you also proved that the demand of this must have “new product” you are selling is going to rock the market. You launched a beautiful website, and you wait for the rise in the performance graph.

Crickets. No traffic.

No traffic means no money and now you are in a dilemma that how would you mend it? Thus to improve it 4 important factors are required.

Backlinks: Backlinks are the incoming hyperlinks from one web page to another website that transfer equity to a website. Backlinks are the most significant factor that determines a site’s search ranking. The link-building strategy should be started as early as possible because it can take months for Google to update a rank. 

Content is the king: Google wants to see that your website should be dynamic and active for it to rank. Having a blog section on your website would do the task. You have to publish content frequently to give your customer a reason to return back.

Keywords: New websites have a hard time competing for top keywords, thus it is best to start with long-tail keywords. Keywords would allow you to attract the targeted audience who are looking for exactly that thing which you might be selling. 

How to do it using Drupal?

Upcycling

The Auraria Library main website is a great example of how upcycling can be achieved with the help of Drupal. The website was powered by Drupal 6, and it was beginning to see its end life. They needed an infrastructural upgrade with the highest priority. In 2016 a project team was established to kick off the journey of revamping the website. 6 months later the website was redesigned with a cloud-based, mobile friendly and localized ready content management system - Drupal 8.

Drupal 8 was chosen due to the fact that the organization enjoyed its scalability, flexibility and rapid availability with impressive community-driven service. Therefore, when a decision was to be made to select the CMS platform, they chose Drupal as their own. 

Thus by keeping longevity in mind, a swift change from Drupal 6 to Drupal 8 ( skipping Drupal 7) was made. 

Due to urgent migration, the project team implemented 80/20 law to break down the development objective into multiple releases. By doing so it not only enabled the possibility of a short first development cycle and helped in launching the website within six months but also bought them with the time to wait for highly contributed D8 modules to mature. 

User experience, increase in ROI, responsive designs, brand engagement, infrastructure improvement, and on-time delivery were the key objectives of the whole project. 

Upgrading 

Upgrading a website using Drupal involves several steps. First, you need to define the source site (make sure core modules like Migrate, Migrate Drupal, Migrate Drupal UI are enabled), then you need to review the pre-upgrade analysis. The upgrade of Drupal 7 to Drupal 8 should be done so that Drupal 8 site is empty. There might be a chance that conflicting IDs are detected, a warning about the conflicting IDs will be shown.

This warning can be dealt with two ways. One is where you ignore it and lose your data and the other one is where you abort it and take an alternative approach.

Now is the time for the upgrade. Depending upon the size and type of content the upgrade accordingly takes the time. 

Why Choose Upcycling Over Upgrading?

Now that you have read all the points and came to this section, a slight idea would be twirling around your mind on what is best for your website.

To give you a clear vision, let’s put it in simpler and accurate words.

To upgrade is to break something down and create a new product from the base material. This might sound great for consumer goods and other relatable things, but not always great for a website. Upgrading is a good choice for organizations that have the time and the money to invest in the whole construction, and also if they are starting to witness its end. For the well-established websites: not a good choice. 

The goal of upcycling is to add value without degrading the product. It is the concept of creating something new out of something old with as little effort as possible. Upcycling is the right choice for all the Drupal-based websites as it uses the features of Drupal 8 in a way that increases the conversions of the website. 

Upcycling and Decoupling 

If a website has a couple of complex backends logic that the website owner doesn't wish to rebuild but is eager to relaunch the frontend, upcycling is the solution. Relaunching the frontend as a decoupled site with Drupal themes and then integrate it with the backend makes more sense. 

Whereas if the backend really needs a major push, but you want to keep the existing frontend without the need of reconstructing it, upcycling could work for that too, after the backend is decoupled. 

Decoupling your entire architecture will enable the website to upcycle individual parts and bring great value to all the end users. It would highly contribute to things like

Infrastructure: Gets the most out of the existing content and website composition. 

User Experience: Improves user experience, design, and front-end without the need of waiting for any launch.

Investment: You are able to witness your investment as soon as possible. 

In the Nutshell

At the end of the day, we want our website to flourish in terms of performance and make improvements to reach the desired bars. 

Upcycling is like a blessing for all the website owners. At Opensense Labs, we help our clients with the transition of their website. Our services not only provides with splendid modifications but also takes care of all your needs and demands. Ping us at hello@opensenselabs.com 

blog banner blog image Drupal Drupal 8 Upgrading Upcycling Rate of investment Performance Decoupled Drupal Website redesign Blog Type Articles Is it a good read ? On

Spinning Code: Drupal 8 Batch Services

1 dzień 4 godziny ago

For this month’s South Carolina Drupal User Group I gave a talk about creating Batch Services in Drupal 8. As a quick side note we are trying to include video conference access to all our meetings so please feel free to join us even if you cannot come in person.

Since Drupal 8 was first released I have been frustrated by the fact that Drupal 8 batch jobs were basically untouched from previous versions. There is nothing strictly wrong with that approach, but it has never felt right to me particularly when doing things in a batch job that I might also want to do in another context – that really should be a service and I should write those core jobs first. After several frustrating experiences trying to find a solution I like, I finally created a module that provides an abstract class that can be used to create a service that handles this problem just more elegantly. The project also includes an example module to provide a sample service.

Some of the text in the slides got cut off by the Zoom video window, so I uploaded them to SlideShare as well:


Quick Batch Overview

If you are new to Drupal batches there are lots of articles around that go into details of traditional implementations, so this will be a super quick overview.

To define a batch you generate an array in a particular format – typically as part of a form submit process – and pass that array to batch_set(). The array defines some basic messages, a list of operations, a function to call when the batch is finished, and optionally a few other details. The minimal array would be something like:

<?php // Setup final batch array. $batch = [ 'title' => 'Page title', 'init_message' => 'Openning message', 'operations' => [], 'finished' => '\some\class\namespace\and\name::finishedBatch', ];

The interesting part should be in that operations array, which is a list of tasks to be run, but getting all your functions setup and the batch array generated can often be its own project.

Each operation is a function that implements callback_batch_operation(), and the data to feed that function. The callbacks are just functions that have a final parameter that is an array reference typically called $context. The function can either perform all the needed work on the provided parameters, or perform part of that work and update the $context['sandbox']['finished'] value to be a number between 0 and 1. Once finished reaches 1 (or isn’t set at the end of the function) batch declares that task complete and moves on to the next one in the queue. Once all tasks are complete it calls the function provided as the finished value of the array that defined the batch.

The finish function implements callback_batch_finish() which means it accepts three parameters: $success, $results, and $operations: $success is true when all tasks completed without error; $results is an array of data you can feed into the $context array during processing; $operations is your operations list again.

Those functions are all expected to be static methods on classes or, more commonly, a function defined in a procedural code block imported from a separate file (which can be provided in the batch array).

My replacement batch service

It’s those blocks of procedural code and classes of nothing but static methods that bug me so much. Admittedly the batch system is convenient and works well enough to handle major tasks for lots of modules. But in Drupal 8 we have a whole suite of services and plugins that are designed to be run in specific contexts that batch does not provide by default. While we can access the Drupal service container and get the objects we need the batch code always feels clunky and out of place within a well structured module or project. What’s more I have often created batches that benefit from having the key tasks be functions of a service not just specific to the batch process.

So after several attempts to force batches and services to play nice together I finally created this module to force a marriage. Even though there are places which required a bit of compromise, but I think I have most of that contained in the abstract class so I don’t have to worry about it on a regular basis. That makes my final code with complex logic and processing far cleaner and easier to maintain.

The Batch Service Interface module provides an interface an an abstract class that implements parts of it: abstract class AbstractBatchService implements BatchServiceInterface. The developer extending that class only needs to define a service that handles generating a list of operations that call local methods of the service and the finish batch function (also as a local method). Nearly everything else is handled by the parent class.

The implementation I provided in the example submodule ends up four simple methods. Even in more complex jobs all the real work could be contained in a method that is isolated from the oddities of batch processing.

<?php namespace Drupal\batch_example; use Drupal\node\Entity\Node; use Drupal\batch_service_interface\AbstractBatchService; /** * Class ExampleBatchService logs the name of nodes with id provided on form. */ class ExampleBatchService extends AbstractBatchService { /** * Must be set in child classes to be the service name so the service can * bootstrap itself. * * @var string */ protected static $serviceName = 'batch_example.example_batch'; /** * Data from the form as needed. */ public function generateBatchJob($data) { $ops = []; for ($i = 0; $i < $data['message_count']; $i++ ) { $ops[] = [ 'logMessage' => ['MessageIndex' => $i + 1], ]; } return $this->prepBatchArray($this->t('Logging Messages'), $this->t('Starting Batch Processing'), $ops); } public function logMessage($data, &amp;$context) { $this->logger->info($this->getRandomMessage()); if (!isset($context['results']['message_count'])) { $context['results']['message_count'] = 0; } $context['results']['message_count']++; } public function doFinishBatch($success, $results, $operations) { drupal_set_message($this->t('Logged %count quotes', ['%count' => $results['message_count']])); } public function getRandomMessage() { $messages = [ // list of messages to select from ]; return $messages[array_rand($messages)]; } }

There is the oddity that you have to tell the service its own name so it can bootstrap itself. If there is a way around that I’d love to know it. But really one have one line of code that’s a bit strange, everything else is now fairly clear call and response.

One of the nice upsides to this solution is you could write tests for the service that look and feel just like any other services tests. The methods could all be called once, and you are not trying to run tests against a procedural code block or a class that is nothing but static methods.

I would love to hear ideas about ways I could make this solution stronger. So please drop me a comment or send me a patch.

Related core efforts

There is an effort to try to do similar things in core, but they look like they have some distance left to travel. Obviously once that work is complete it is likely to be better than what I have created, but in the meantime my service allows for a new level of abstraction without waiting for core’s updates to be complete.

OSTraining: How to Create a Voting System in Drupal 8

1 dzień 18 godzin ago

One of OSTraining’s customers asked how to implement content voting on their site. 

In Drupal 7, the popular choice was the Fivestar module, but that's still not ready for Drupal 8.

In this tutorial, I'll show you how to use the Votingapi Widgets module in Drupal 8. This module makes use of a “Rating” field, which you can customize and insert into your content.

OSTraining: How to Create CSS and Javascript Animations in Drupal 8

1 dzień 19 godzin ago

There are multiple JavaScript and CSS libraries on the internet. They allow you to animate parts of your site and make them look more attractive.

The Animations module makes it easy to include animations on your Drupal site. 

There's a full list of the animations on the module page, but they include such wonderfully named animations as swing, tada, wobble, jello, bounceIn, bounceOut, fadeIn, rollOut, zoomIn, slideInRight and more.

In this tutorial, I'll show how to install and use the required libraries and the Animations module..

OSTraining: How to Create a Contact Form in Drupal 8

1 dzień 19 godzin ago

One of OSTraining’s members asked how to create a following web form with the Webform module:

  • The site has four regions to be contacted: NE, SE, NW, and SW.
  • Each region will have their own contact person/team.
  • The user must be able to select one or more of the regions to contact at the same time, using checkboxes.
  • All the submittions must be BCC-ed to the main administrator.
  • If needed, the site owner should be able to add one or more email recipients for each region.

In this tutorial, you will learn how to meet these user requirements using the Webform module.

OSTraining: Videos to Get you Started with Drupal Development

1 dzień 19 godzin ago
How do I get started with Drupal development?

That's a common question we get from people who join OSTraining for the first time. They want to know about the skills they will need, and what kind of classes they should take.

In this guide, I'll give you an overview to help you get started with Drupal development.

Ben's SEO Blog: 6 Tips to Rock Drupal 8 SEO

3 dni 4 godziny ago

This article was originally written on 2017-04-12 but has been updated with current information and SEO best practices.

Drupal is phenomenal for SEO. When you use Drupal 8 for your content management system, you have a powerful tool to rock search engine optimization. I’ve worked in Drupal for 12 years and I’ve experienced firsthand how quickly search engines respond to a well-optimized Drupal website. I’ve seen customers triple their traffic in weeks after upgrading from another platform. I’ve seen competitive advantages from site-wide optimizations like RDF or AMP that put my clients on the cutting edge of SEO because they use Drupal. The benefits are a faster website, higher rankings and more traffic.

One of the main reasons Drupal is the content management system of... Read the full article: 6 Tips to Rock Drupal 8 SEO

Acquia Developer Center Blog: Building Usable Conversations: How to Approach Conversational Interfaces

3 dni 10 godzin ago

To kick off 2019 properly, the Experience Express is taking a break from Drupal and web development to consider an oft-forgotten component of new digital experiences in the conversational space. Though many organizations, some of Acquia's customers included, have leapt headlong into building conversational interfaces, sometimes it can be difficult in such a newfangled paradigm to consider all possible angles where things can go awry.

Tags: acquia drupal planet