Drupal Planet

Subscribe to Drupal Planet feed
Drupal.org - aggregated feeds in category Planet Drupal
Updated: 5 hours 39 min ago

CiviCRM Blog: The quest for performance improvements - 4th sprint

January 9, 2017 - 10:13am

Last week we had a fourth sprint to improve CiviCRM performance at the socialist party. 

During this sprint we started with looking at why the screen for adding and editing memberships loaded slow. The issue reported was that it took some time before the end date field jumped from the right side of the screen to the middle of the screen. It turned out that as long as the field was displayed at the right side the screen was still loading.  Timing this gave a time of about 18 seconds before the screen was fully loaded.

We discovered a few causes:

  • The javascript files which the browser had to download are over 2MB in size
  • Every request in CiviCRM was also logged in Google Analytics and in Piwik.
  • The PHP function getGroupsHierarchy in CRM/Contact/BAO/Group.php took around 900ms to execute (see the issue: https://issues.civicrm.org/jira/browse/CRM-19831)
  • On that same screen the custom fields are retrieved with an AJAX request and in each request all contributions linked to the membership are also retrieved.

The getGroupsHierarchy function is performing slow because it needed to loop three times through all groups in the database in this case there are around 2.687 groups. In addition one of the loops uses the php function array_merge to merge the result of the loop. The array_merge function is known for performing slow when an array contains more than 40 elements.

After rewriting the function we reduced the execution time from 900ms to 20ms.  At https://github.com/civicrm/civicrm-core/pull/9633/files you can find the patch of the rewritten code.  In that patch we use for loops and not foreach as we discovered that a for loop is performing a lot faster than a foreach. If we replace the for to a foreach the total time of execution of that function will drop to 2.360 ms a factor of 100 slower.

We have also turned off Google Analytics and Piwik for CiviCRM pages as there is no need for this. Nobody really knew why it was turned on in the first place.

After fixing the getGroupsHierarchy function we reduced the total loading time in the browser from 18  seconds to 10 seconds. Which is still slow!

Read the previous blog posts:

Drupal
Categories: Blogs

MD Systems blog: Current status of Media in Drupal 8 core and next steps

January 9, 2017 - 4:44am
The Media team finished the exciting and successful year 2016 with a Drupal 8 core media sprint in Berlin and we were part of it. Now, what are the next steps?
Categories: Blogs

Web Omelette: Choose your theme dynamically in Drupal 8 with theme negotiation

January 9, 2017 - 4:00am

Have you ever needed to render certain pages (or groups of pages) with a different theme than the default one configured for the site? I did. And in this article I'm going to show you how it's done in Drupal 8. And like usual, I will illustrate the technique using a simple use case.

The requirement

Let's say we have a second theme on our site called gianduja since we just love the chocolate from Torino so much. And we want to apply this theme to a few custom routes (the content rendered by the respective controllers is not so important for this article). How would we go about implementing this in a custom module called Gianduja?

The solution

First, we need a route option to distinguish these routes as needing a different theme. We can call this option _custom_theme and its value can be the machine name of the theme we want to render with it. This is how a route using this option would look like:

gianduja.info: path: '/gianduja/info' defaults: _controller: '\Drupal\gianduja\Controller\GiandujaController::info' _title: 'About Gianduja' requirements: _permission: 'access content' options: _custom_theme: 'gianduja'

Just a simple route for our first info page. You can see our custom option at the bottom which indicates the theme this route should use to render its content in. The Controller implementation is outside the scope of this article.

However, just adding an option there won't actually do anything. We need to implement a ThemeNegoatiator that looks at the routes as they are requested and switches the theme if needed. We do this by creating a tagged service.

So let's create a simple class for this service inside the src/Theme folder (directory/namespace not so important):

namespace Drupal\gianduja\Theme; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Theme\ThemeNegotiatorInterface; /** * Our Gianduja Theme Negotiator */ class ThemeNegotiator implements ThemeNegotiatorInterface { /** * {@inheritdoc} */ public function applies(RouteMatchInterface $route_match) { $route = $route_match->getRouteObject(); if (!$route instanceof Route) { return FALSE; } $option = $route->getOption('_custom_theme'); if (!$option) { return FALSE; } return $option == 'gianduja'; } /** * {@inheritdoc} */ public function determineActiveTheme(RouteMatchInterface $route_match) { return 'gianduja'; } }

As you can see, all we need to do is implement the ThemeNegotiatorInterface which comes with two methods. The first, applies(), is the most important. It is run on each route to determine if this negotiator provides the theme for it. So in our example we examine the Route object and see if it has the option we set in our route. The second, determineActiveTheme() is responsible for providing the theme name to be used in case applies() has returned TRUE for this route. So here we just return our theme name. All pretty straightforward.

Lastly though, we need to register this class as a service in our gianduja.services.yml file:

services: theme.negotiator.gianduja: class: Drupal\gianduja\Theme\ThemeNegotiator tags: - { name: theme_negotiator, priority: -50 }

This is a normal definition of a service, except for the fact that we are applying the theme_negotiator tag to it to inform the relevant container compiler pass that we are talking about a theme negotiator instance. Additionally, we are also setting a priority for it so that it runs early on in the theme negotiation process.

And that is pretty much it. Clearing the cache and hitting our new route should use the gianduja theme if one exists and is enabled.

Using this example, we can create more complex scenarios as well. For one, the theme negotiator class can receive services from the container if we just name them in the service definition. Using these we can then run complex logics to determine whether and which theme should be used on a certain route. For example, we can look at a canonical route of an entity and render it with a different theme if it has a certain taxonomy tag applied to it. There is quite a lot of flexibility here.

Categories: Blogs

Platform.sh: 2016, The Year We Won PHP

January 8, 2017 - 9:00pm

First, a joyous and productive 2017 to you all. 2016 was really great for us as a growing company and the new year is a great time to look back and share with you, our dear clients and community, our journey.

The title of the post is audacious, very possibly a hyperbole. There are bigger players than us out there. We don’t claim the highest market share. We claim we have become an obvious choice for ambitious projects. Let me make the case.

Over the course of last year, the leading vendors in the PHP enterprise space Magento, eZ Platform, Typo3, and most recently Symfony - the PHP framework of frameworks - announced their cloud platform to be on Platform.sh. Since its inception two and a half years ago, Platform.sh has already become a leader in the whole PHP space. How did this come about?

Categories: Blogs

jordanpagewhite: Drupal 8 Front-End Architecture

January 8, 2017 - 8:00pm

I recently read Front-End Architecture for Design Systems by Micah Godbolt (BK1). It is a fantastic evaluation of front-end architecture and strategy. The book isn’t specifically for Drupal developers, but the concepts laid out in the book are relevant to all front-end developers and they are easily applicable to Drupal 8 projects. In this post, I want to build a couple of components and discuss different front-end architecture approaches for Drupal 8 projects, specifically using the concepts in Godbolt’s book.

Categories: Blogs

jordanpagewhite: Add region modifier class to menu

January 8, 2017 - 8:00pm

I asked this in the DrupalTwig slack channel a couple days ago:

Categories: Blogs

Platform.sh: HTTP/2 Support Announced!

January 7, 2017 - 8:00pm

All the fastness just got faster. A couple of days ago we finished 2016 in beauty, announcing PHP 7.1 which allows you to do some incredibly fast PHP apps with stuff like ReactPHP for example.

Let’s start 2017 with some more fastness juice flowing. HTTP/2 is now supported on all public Platform.sh regions.

What do you need to do to benefit from the incredible performance gains this will give your site?

Nothing. It just works (as long as you have HTTPS enabled, which you should anyway).

Categories: Blogs

Janez Urevc: Join us at the next Drupal Media sprint at the Mountain camp in Davos!

January 6, 2017 - 6:19pm
Join us at the next Drupal Media sprint at the Mountain camp in Davos!

Are you excited about the recent improvements in Drupal core Media? Would you like to join us at one of the next sprints and help us reach our goals? Now you can!

Drupal Mountain Camp 2017 will happen between 16th and 19th February in the lovely Davos. Drupal, code community, snow, fondue, outdoor activities and much more. Definitely something that should not be missed!

And the best part? There will be Media sprint going on throughout the event. Eager to join? Simply add yourself to the sprint attendance list and show up. We promise you the best sprint ever!

slashrsm Fri, 06.01.2017 - 23:19 Tags Drupal Media Sprint Enjoyed this post? There is more! Results of the Drupal 8 media sprint Presentations about various Drupal 8 media modules Call for Drupal 8 media ecosystem co-maintainers Drupal dev environment on Docker
Categories: Blogs

Drupal Blog: Moving the Drupal 8 workflow initiative along

January 6, 2017 - 1:49pm

Republished from buytaert.net

Nine months ago I wrote about the importance of improving Drupal's content workflow capabilities and how we set out to include a common base layer of workflow-related functionality in Drupal 8 core. That base layer would act as the foundation on which we can build a list of great features like cross-site content staging, content branching, site previews, offline browsing and publishing, content recovery and audit logs. Some of these features are really impactful; 5 out of the top 10 most requested features for content authors are related to workflows (features 3-7 on the image below). We will deliver feature requests 3 and 4 as part of the "content workflow initiative" for Drupal 8. Feature requests 5, 6 and 7 are not in scope of the current content workflow initiative but still stand to benefit significantly from it. Today, I'd like to provide an update on the workflow initiative's progress the past 9 months.

The top 10 requested features for content creators according to the 2016 State of Drupal survey. Features 1 and 2 are part of the media initiative for Drupal 8. Features 3 and 4 are part of the content workflow initiative. Features 5, 6 and 7 benefit from the content workflow initiative.

Configurable content workflow states in Drupal 8.2

While Drupal 8.0 and 8.1 shipped with just two workflow states (Published and Unpublished), Drupal 8.2 (with the the experimental Content moderation module) ships with three: Published, Draft, and Archived. Rather than a single 'Unpublished' workflow state, content creators will be able to distinguish between posts to be published later (drafts) and posts that were published before (archived posts).

The 'Draft' workflow state is a long-requested usability improvement, but may seem like a small change. What is more exciting is that the list of workflow states is fully configurable: you can add additional workflow states, or replace them with completely different ones. The three workflow states in Drupal 8.2 are just what we decided to be good defaults.

Let's say you manage a website with content that requires legal sign-off before it can be published. You can now create a new workflow state 'Needs legal sign-off' that is only accessible to people in your organization's legal department. In other words, you can set up content workflows that are simple (like the default one with just three states) or that are very complex (for a large organization with complex content workflows and permissions).

This functionality was already available in Drupal 7 thanks to the contributed modules like the Workbench suite. Moving this functionality into core is useful for two reasons. First, it provides a much-requested feature out of the box – this capability meets the third most important feature request for content authors. Second, it encourages contributed modules to be built with configurable workflows in mind. Both should improve the end-user experience.

Support for different workflows in Drupal 8.3

Drupal 8.3 (still in development, planned to be released in April of 2017) goes one step further and introduces the concept of multiple types of workflows in the experimental Workflows module. This provides a more intuitive way to set up different workflows for different content types. For example, blog posts might not need legal sign-off but legal contracts do. To support this use case, you need to be able to setup different workflows assigned to their appropriate content types.

What is also interesting is that the workflow system in Drupal 8.3 can be applied to things other than traditional content. Let's say that our example site happens to be a website for a membership organization. The new workflow system could be the technical foundation to move members through different workflows (e.g. new member, paying member, honorary member). The reusability of Drupal's components has always been a unique strength and is what differentiates an application from a platform. By enabling people to reuse components in interesting ways, we turn Drupal into a powerful platform for building many different applications.

Drupal 8.3 will support multiple different editorial workflows. Each workflow can define its own workflow states as well as the possible transitions between them. Each transition has permissions associated with them to control who can move content from one state to another.

Workspace interactions under design

While workflows for individual content items is very powerful, many sites want to publish multiple content items at once as a group. This is reflected in the fourth-most requested feature for content authors, 'Staging of multiple content changes'. For example, a newspaper website might cover the passing of George Michael in a dedicated section on their site. Such a section could include multiple pages covering his professional career and personal life. These pages would have menus and blocks with links to other resources. 'Workspaces' group all these individual elements (pages, blocks and menus) into a logical package, so they can be prepared, previewed and published as a group. And what is great about the support for multiple different workflows is that content workflows can be applied to workspaces as well as to individual pieces of content.

We are still in the early stages of building out the workspace functionality. Work is being done to introduce the concept of workspaces in the developer API and on designing the user interface. A lot remains to be figured out and implemented, but we hope to introduce this feature in Drupal 8.5 (planned to be released in Q2 of 2018). In the mean time, other Drupal 8 solutions are available as contributed modules.

An outside-in design that shows how content creators could work in different workspaces. When you're building out a new section on your site, you want to preview your entire site, and publish all the changes at once. Designed by Jozef Toth at Pfizer.

Closing thoughts

We discussed work on content workflows and workspaces. The changes being made will also help with other problems like content recovery, cross-site content staging, content branching, site previews, offline browsing and publishing, and audit logs. Check out the larger roadmap of the workflow initiative and the current priorities. We have an exciting roadmap and are always looking for more individuals and organizations to get involved and accelerate our work. If you want to get involved, don't be afraid to raise your hand in the comments of this post.

Thank you

I tried to make a list of all people and organizations to thank for their work on the workflow initiative but couldn't. The Drupal 8 workflow initiative borrows heavily from years of hard work and learnings from many people and organizations. In addition, there are many people actively working on various aspects of the Drupal 8 workflow initiative. Special thanks to Dick Olsson (Pfizer), Jozef Toth (Pfizer), Tim Millwood (Appnovation), Andrei Jechiu (Pfizer), Andrei Mateescu (Pfizer), Alex Pott (Chapter Three), Dave Hall (Pfizer), Ken Rickard (Palantir.net) and Ani Gupta (Pfizer). Also thank you to Gábor Hojtsy (Acquia) for his contributions to this blog post.

Categories: Blogs

DrupalCon News: DevOps:  The Philosophical Movement

January 6, 2017 - 12:47pm

As Gene Kim, American entrepreneur and founder of Tripwire, says, DevOps is “not yet a precise collection of practices, descriptive or prescriptive.”[1]  Similarly, as Drupal enters its own era of philosophical movement towards Drupal 8, what more fitting time to focus around how we can bridge the gap between Developers and Operations to further improve our DevOps workflows.

In the DevOps Track Description, we drew comparisons between Development and Operations being like Peanut Butter and Chocolate.  Some people might think this analogy is stretching the limits or just an easy way to justify having a bunch of Peanut Butter Cups on my desk but the correlation between Peanut Butter and Chocolate is the same sort of philosophical relationship we look for between Development and Operations teams.  This philosophical relationship is what we hope to explore during the DevOps track at DrupalCon Baltimore.

Categories: Blogs

ThinkShout: Using Google Docs and Migrate to Populate Your Drupal Site, Part 1

January 6, 2017 - 12:00pm

The problem:

Content management systems are extremely powerful, in that they let developers focus on what they do best – build the infrastructure of a site, while allowing content editors to do what they do best – create content.

But this can be a problem when building a new feature. How often have you heard something to this effect:

Developer: “That blank spot right there will be a neat slideshow, once you build it.”

Client: “I thought I was paying you to build it.”

The separation between content and development can lead to missed edge cases, unfounded assumptions, and wasted time for everyone involved.

There are a few workarounds to this problem. We often prototype our sites with dummy content (insert your favorite Ipsum here). But this, without fail, leads to some nasty surprises when the client starts entering real content. It’s suddenly much longer (or shorter) than the designer or developer intended. Or maybe the images are far too big. Or they’re all portraits where we expected landscapes. In short, the arguments made against using Lorem Ipsum in designs go doubly once you start actually implementing fields on your Drupal site.

So what about more meaningful content – maybe exported from another source? Modules like Default Content allow developers to export certain content for import during the initial site build. But that content has the disadvantage of requiring a developer’s intervention. The more of a nuisance it is to update the content, sync the database, change the fields, etc, the less likely you are to keep the content up-to-date.

At ThinkShout, we want to populate our client’s sites with content as soon as possible.

It doesn’t need to be the final content…

But it should be real content.

It shouldn’t necessarily be exactly what’s on the old site…

But it ought to be close…

In other words, our initial content needs to be easy to change – easy enough that the client can do it. Easy enough that the developers don’t have to take a walk around the block to calm down when they find out the fields are changing (again). Easy.

Our Solution Part 1: Migrate

“But isn’t Migration to Drupal hard?” I hear you saying.

It certainly was in Drupal 7, where the Migrate module had a (deserved) reputation for being difficult to use. Migrating from one Drupal site to another, or even from Wordpress to Drupal was relatively smooth, but if you really wanted to do something unusual, like migrate from a less-common CMS to Drupal, you were going to be writing a lot of custom code “glue” to get it all working.

In D8, Migrations have been moved to core. This means a few things. First, it means the core concept of entities is baked right in. In D7 migrations, you often had to hunt around for a plugin, hoping someone had written a Destination Handler for your favorite oddball entities, like Redirects, or Addresses, or the dreaded Field Collections. In D8, an entity is an entity.

As such, with a solid knowledge of the helpful migration plugins and two essential contributed modules, Migrate Tools and Migrate Plus, you can write a robust migration of both content and config entities without writing code more complicated than a few .yml files. If you don’t believe me, I encourage you to try upgrading your D6 or D7 site to D8 on a local or dev environment to see how much of your data is already in there.

That being said, what if I don’t have an existing site? Or what if I want to implement a new content strategy to go along with my fancy new site?

Our Solution Part 2: Google Sheets

Throw that new content into a Google Doc!

Yes, spreadsheets are old school, but let’s take a minute to appreciate what they give us.

  • Spreadsheets are familiar. When it comes right down to it, spreadsheets are the universal language of business. Putting content into little boxes gives us the ability to move those boxes around, highlight them, and sort them – few UX experiences can get you so much information so quickly.

  • Spreadsheets are dynamic. It doesn’t take hours of database planning to get information into a spreadsheet. Nor does it take hours of testing to rearrange or remove items from a spreadsheet. It doesn’t demand anything of your data architect other than “organize things by columns and rows.”

  • Spreadsheets are sharable. We can enable a Google spreadsheet and share it with the client in a few minutes. Clients can start entering their data from day 1 (alright, maybe day 2 or 3). And they can update content as needed – take it out of the sheet, update things, and change them.

  • Google spreadsheets have revisioning built in. If someone really messes up a Google Doc, you can go back through its history and revert it. It’s a nice compromise between committing all your initial content to source control or just letting it live freely.

Ready to give it a shot?

Stay tuned for Part 2 of this series, where I go into detail about how to set up your own Google sheet Drupal 8 migration.

Can’t wait? Check out the Migrate Google Sheets module now! We’ve even set up a sample site where content comes entirely from an external spreadsheet to help you get started.

Categories: Blogs

InternetDevels: Drupal as CMS vs .NET based CMS: which one to choose for your web development?

January 6, 2017 - 9:13am

You used to know Internetdevels as a reliable Drupal development company. We are always trying to satisfy your every need, which is why our team was recently enriched with specialists dealing with .NET. Now you have an opportunity to choose a CMS appropriate for your site.

Read more
Categories: Blogs

Cheppers blog: Collecting Drupal logs to Amazon Kinesis

January 6, 2017 - 8:56am

I was asked to find a way to collect log messages from 100 websites that were running on Drupal (version 7) and make them available for evaluation as one of the last steps of a long-running test suite.  Here is one of the ways Drupal logs can be collected into a Kinesis stream.

Categories: Blogs

Amazee Labs: Drupal Mountain Camp: Call for Sessions closing soon!

January 6, 2017 - 8:33am
Drupal Mountain Camp: Call for Sessions closing soon!

With 16 February 2017 fast-approaching, Drupal Mountain Camp is closing the call for sessions at midnight CET on Sunday, 8 January, so hurry and submit your talk today.

Daniel Lemon Fri, 01/06/2017 - 13:33 What and When is Drupal Mountain Camp?

The camp is designed to mix the beauty of the Swiss Alps, sprinkled in snow, with the warmth of the Drupal community. It's a perfect combination of fresh tracks for those who ski or snowboard with inspirational talks by amazing people topped with Swiss cheese & chocolate.

The camp will happen from 16 to 19 February 2017 at the Davos Congress Centre.

Final call for sessions

The closing for call for sessions is rapidly approaching, so submit your talks as soon as possible! There is already over 30 great sessions with 2 confirmed key-notes by Laura Gaetano and Preston So.

Does that sound interesting and do you want to know more about the process to submit your session topic? Well, read on:

How can I submit a session?

So you've got something you'd like to talk about, awesome, here's how you can submit a session:

  1. Head on over to the submit a session link.
  2. Think of a catchy-title and fill in the Session Title.
  3. What is your talk about? Try to write 4-5 lines about what you'd like to talk about in the Description textbox.
    • Note: you can add images if it helps portray your talk.
  4. Select what kind of Session Type (how much time) you'd like.
  5. Select the appropiate Tracks - you can select multiple if your talk covers various topics.
  6. Select the Level of expertise - is it more of a beginner talk or does it become quite advanced with technical terms?
  7. Don't forget to add your Speaker name and Contact email.
Well that sounds easy, but why should I submit a talk?

Public speaking rates high among the top 5 phobias by people right alongside going to the dentist and flying. Why would anyone put themselves through that? Well, everyone has their own reasons, but here's what I've gathered.

  • Giving a talk will require a lot of work and preparation, but don't let that put you off. It will pay off in the end.
  • People who attend your talk are generally looking for help in your specific topic, so this will be a great time for networking.
  • You'll be noticed and people will tell you that you're cool.
    • Ok, maybe you don't want to be noticed, and maybe you're fine with not being called cool, but you'll definetly have fun talking.
  • You'll feel way more confident afterwards, which might be a good enough boost for you to jump on a snowboard and hit the slopes on the weekend.

There are some great talks already submitted for example on topics like Migrations, Styleguide, and Paragraphs

"I don't know if my session is good enough."

Don't worry. There's help available, you can contact Josef / dasjo directly or get in touch with the organising team via the contact email on the camps website. We are happy to provide feedback about possible talk topics and the general agenda.

Is it fun to speak at events?

Yes. Not only will you further cement your knowledge on the topic by giving a talk about it, you'll also learn from your peers who attend your talk.

So, go ahead and submit your talk and we'll see you 16-19 of February in Davos, Switzerland. In the meantime, follow the camp on Twitter.

Categories: Blogs

Mike Crittenden: The Drupal Project Productivity Curve

January 6, 2017 - 8:00am
The Drupal Project Productivity Curve

There are a lot of things that make Drupal projects unique from your typical software development projects, but one of the most interesting to me is the productivity curve.

Specifically, Drupal projects tend to have lots of visible progress at the start and then things slow down considerably. In contrast, many (most?) non-Drupal projects are the opposite - they have little to show at the beginning but things are being cranked out really quickly closer to the end.

Here's a very technical graph to illustrate:

A typical Drupal project

Drupal projects make the first 80% pretty easy and the last 20% really freaking hard, which is the exact opposite of many other common frameworks or technologies. Let's look at an example.

You're building a community site for shoelace enthusiasts. It contains a forum, a blog with commenting, some basic page content, media upload and browsing, photo albums, whatever. All the normal stuff that you see a lot.

The interesting thing here is that Drupal allows you to build simple versions of all of that stuff really quickly in the GUI without having to do any real "work" (i.e., programming). You can have a working (for some definition of that word) site up in a matter of days or a couple weeks at most that satisfies the high level requirements.

But of course, that's not good enough. We just have a bunch of generated markup dumped onto pages, which looks horrible and is nowhere near the mockups. We need theming, and we have a boat load of tweaks to make to functionality. This field needs to be split into two columns. That sidebar needs to only appear on pages that match a specific URL pattern. The blog needs to allow for customizing the sort order of the first 5 items. We need an extra wrapper div around a specific field so that our stupid 3rd party JS lib can find it. We need to add a custom exposed filter that Views doesn't support out of the box. We have to change the available values for a select list but Drupal is complaining that that field already has data. Drupal makes all of these things difficult because it has to, by nature of what Drupal is.

What we basically had after those first couple weeks is a prototype. Drupal is in a world of its own (in a good way) when it comes to prototyping CRUD. It's all the stuff that comes in the conversion from the prototype to the real, living-and-breathing, hard-to-break-by-even-the-dumbest-of-users, looks-like-something-not-designed-by-a-programmer, website. Altering markup is tough (yes, even if you're just overriding a template). Theming in general is tough. Making little tweaks to functionality or behavior is tough. Drupal is just opinionated to the point that stuff that would be easy in non-Drupal sites becomes a pain. And again, that's not a bad thing. It's just a natural result of what makes Drupal Drupal.

A Typical Non-Drupal Project

(First of all, this is pretty wishy washy because "Non-Drupal" can mean anything from Dreamwaver generated to whatever the latest Rails release is now. So bear with me and keep an open mind for now.)

Remember when I said Drupal makes the first 80% really easy and the last 20% really hard? Well, you must know what's coming next then. 

In general, non-Drupal projects tend to make the first 80% tougher than Drupal, but the last 20% is drastically easier.

It takes a while to create your DB structure, models or data structure, admin forms with things like WYSIWYG and image cropping, user authentication and permissions, content detail pages and listings, user facing forms, user registration and password reminders, comments on content items with threading, etc. All of that stuff can be a big pain, and there's drastically more manual work involved than with Drupal.

But once you have that done, and you've reached the "working" site stage mentioned in the previous section, the rest is really easy. It's easy to split something into 2 columns when you wrote the markup in the first place. It's easy to alter behavior that you yourself defined in code. It's easy to decide when and where a sidebar should appear when you are the one that told it where/how to appear in the first place, in code.

Theming is quicker. Tweaks are quicker. Moving this thing into the footer and that thing into the sidebar is quicker. All of the types of things that tend to make up the last 20% of the project are just much easier to do than if you were using Drupal

Why the difference?

Why are the 80% vs. 20% times so different between Drupal and non-Drupal projects? I think it comes down to one thing: who wrote the code.

One of the main draws of Drupal is that you can accomplish so much without having to write a line of code. This means that a lot of your functionality is powered by code that someone else wrote.

Not writing that code means that it's tougher for you to change things when needed, for two reasons:

  1. You just aren't as familiar with it. It takes you a while to understand what the original writers were doing, how they were doing it, and what the best way to make your change will be. The bigger the module that you're altering, the tougher this tends to be, and that's unfortunate because most of the really common modules (i.e., the ones that most commonly need to have their behavior altered) are pretty huge. 
  2. You can't just go edit the file wherever it exists in core or contrib, like you could if it was custom code. Hacking contrib or core is a big no-no in Drupal-land so you have to spend your time in alter hooks, preprocess functions, overridden templates, or patches. There's nothing quite like spending hours trying to find a hook that would work or a template that you could override (and with what naming convention?!) just to add a stupid wrapper div to a stupid thing you need to wrap, which would take 2 minutes if you wrote the template to begin with.

So that's the difference. That's why the first 80% is easier with Drupal (because you're able to stick to the pre-written code) and the last 20% is harder (because you've having to extend/alter/theme the pre-written code). 

So what?

Why does it matter? Slow start and fast finish vs. fast start and slow finish, who cares as long as it all gets done eventually and in about the same amount of time?

Well, clients care. You know how we're supposed to be under-promising and over-delivering? Using a fast start/slow finish approach makes this kind of tricky. Stakeholders often don't see "percent complete" in terms of hours spent vs. the budget, or time left until the deadline, or any of those actual numeric factors.

Instead, it often ends up just being a "feel" thing. Wow, the site already works, we're really moving fast! I think we may beat the deadline! It "feels" like we've gotten a lot done! We already can add/edit/delete content with all of these fields, and it all appears on the site, and it's only been 3 weeks! All that's left is the tweaking!

You see where I'm going with this? If you show that much visible progress to a not-super-technical client in the first few weeks, then they can expect that much visible progress on a regular basis. It's a bit disheartening as a client to see so much progress in a few weeks, and then only little bits at a time for the next few months.

Well, what's the answer?

Yeah yeah, everything sucks, but what can we do about it? Sadly, I don't think there is a silver bullet.

One thing that can help is to make more of a focus on feature-based scheduling. If you're starting the project by having everyone lay the foundation (fields, content types, listing pages, etc.) for all of the features, then iterating on top of that by theming all of the features, then you run into the problems described above. That's no good.

But if you get everyone working on the same feature (or 2 or 3 features if you have a really big team), and push it through from start to finish before moving onto the next thing, then that at least gets you to "complete" with a specific thing more quickly than if you sort of built them all out at once.

But that's not exactly a revolutionary idea. We've all heard of sprints and MVPs and iterative development, which is why I certainly wouldn't call that approach a silver bullet; it's more like a best practice at this point.

Other than that, I think it's just important that clients are made aware and expectations are set. Make sure they know that they'll see lots of changes at first and then the visible changes will slow down because that's just the way Drupal is. And work really really hard to find places where you can show them complete features, or even better, hand them off so that the clients can play with them in a client-facing dev environment somewhere.

Am I saying that this is a reason to avoid Drupal? Absolutely not. I think Drupal is awesome, and the amount of work you can get done without coding has many pros which far outweigh the one con mentioned in this post. I'm just saying that this is a caveat to keep in mind, and plan ahead for, and explain to clients ahead of time.

mcrittenden Fri, 01/06/2017 - 07:00
Categories: Blogs

Dries Buytaert: Moving the Drupal 8 workflow initiative along

January 6, 2017 - 4:24am

Nine months ago I wrote about the importance of improving Drupal's content workflow capabilities and how we set out to include a common base layer of workflow-related functionality in Drupal 8 core. That base layer would act as the foundation on which we can build a list of great features like cross-site content staging, content branching, site previews, offline browsing and publishing, content recovery and audit logs. Some of these features are really impactful; 5 out of the top 10 most requested features for content authors are related to workflows (features 3-7 on the image below). We will deliver feature requests 3 and 4 as part of the "content workflow initiative" for Drupal 8. Feature requests 5, 6 and 7 are not in scope of the current content workflow initiative but still stand to benefit significantly from it. Today, I'd like to provide an update on the workflow initiative's progress the past 9 months.

The top 10 requested features for content creators according to the 2016 State of Drupal survey. Features 1 and 2 are part of the media initiative for Drupal 8. Features 3 and 4 are part of the content workflow initiative. Features 5, 6 and 7 benefit from the content workflow initiative.Configurable content workflow states in Drupal 8.2

While Drupal 8.0 and 8.1 shipped with just two workflow states (Published and Unpublished), Drupal 8.2 (with the the experimental Content moderation module) ships with three: Published, Draft, and Archived. Rather than a single 'Unpublished' workflow state, content creators will be able to distinguish between posts to be published later (drafts) and posts that were published before (archived posts).

The 'Draft' workflow state is a long-requested usability improvement, but may seem like a small change. What is more exciting is that the list of workflow states is fully configurable: you can add additional workflow states, or replace them with completely different ones. The three workflow states in Drupal 8.2 are just what we decided to be good defaults.

Let's say you manage a website with content that requires legal sign-off before it can be published. You can now create a new workflow state 'Needs legal sign-off' that is only accessible to people in your organization's legal department. In other words, you can set up content workflows that are simple (like the default one with just three states) or that are very complex (for a large organization with complex content workflows and permissions).

This functionality was already available in Drupal 7 thanks to the contributed modules like the Workbench suite. Moving this functionality into core is useful for two reasons. First, it provides a much-requested feature out of the box – this capability meets the third most important feature request for content authors. Second, it encourages contributed modules to be built with configurable workflows in mind. Both should improve the end-user experience.

Support for different workflows in Drupal 8.3

Drupal 8.3 (still in development, planned to be released in April of 2017) goes one step further and introduces the concept of multiple types of workflows in the experimental Workflows module. This provides a more intuitive way to set up different workflows for different content types. For example, blog posts might not need legal sign-off but legal contracts do. To support this use case, you need to be able to setup different workflows assigned to their appropriate content types.

What is also interesting is that the workflow system in Drupal 8.3 can be applied to things other than traditional content. Let's say that our example site happens to be a website for a membership organization. The new workflow system could be the technical foundation to move members through different workflows (e.g. new member, paying member, honorary member). The reusability of Drupal's components has always been a unique strength and is what differentiates an application from a platform. By enabling people to reuse components in interesting ways, we turn Drupal into a powerful platform for building many different applications.

Drupal 8.3 will support multiple different editorial workflows. Each workflow can define its own workflow states as well as the possible transitions between them. Each transition has permissions associated with them to control who can move content from one state to another.Workspace interactions under design

While workflows for individual content items is very powerful, many sites want to publish multiple content items at once as a group. This is reflected in the fourth-most requested feature for content authors, 'Staging of multiple content changes'. For example, a newspaper website might cover the passing of George Michael in a dedicated section on their site. Such a section could include multiple pages covering his professional career and personal life. These pages would have menus and blocks with links to other resources. 'Workspaces' group all these individual elements (pages, blocks and menus) into a logical package, so they can be prepared, previewed and published as a group. And what is great about the support for multiple different workflows is that content workflows can be applied to workspaces as well as to individual pieces of content.

We are still in the early stages of building out the workspace functionality. Work is being done to introduce the concept of workspaces in the developer API and on designing the user interface. A lot remains to be figured out and implemented, but we hope to introduce this feature in Drupal 8.5 (planned to be released in Q2 of 2018). In the mean time, other Drupal 8 solutions are available as contributed modules.

An outside-in design that shows how content creators could work in different workspaces. When you're building out a new section on your site, you want to preview your entire site, and publish all the changes at once. Designed by Jozef Toth at Pfizer.Closing thoughts

We discussed work on content workflows and workspaces. The changes being made will also help with other problems like content recovery, cross-site content staging, content branching, site previews, offline browsing and publishing, and audit logs. Check out the larger roadmap of the workflow initiative and the current priorities. We have an exciting roadmap and are always looking for more individuals and organizations to get involved and accelerate our work. If you want to get involved, don't be afraid to raise your hand in the comments of this post.

Thank you

I tried to make a list of all people and organizations to thank for their work on the workflow initiative but couldn't. The Drupal 8 workflow initiative borrows heavily from years of hard work and learnings from many people and organizations. In addition, there are many people actively working on various aspects of the Drupal 8 workflow initiative. Special thanks to Dick Olsson (Pfizer), Jozef Toth (Pfizer), Tim Millwood (Appnovation), Andrei Jechiu (Pfizer), Andrei Mateescu (Pfizer), Alex Pott (Chapter Three), Dave Hall (Pfizer), Ken Rickard (Palantir.net) and Ani Gupta (Pfizer). Also thank you to Gábor Hojtsy (Acquia) for his contributions to this blog post.

Categories: Blogs

ARREA-Systems: Simple twitter feed with custom block

January 5, 2017 - 8:08pm
Simple twitter feed with custom block Fri, 01/06/2017 - 08:08 In this article, we will present how we built a simple twitter feed in Drupal 8 with custom block and without any custom module. This block will display a list of tweets pulled from a custom list as in the example shown in the side bar.
Categories: Blogs

Lullabot: Journey Into the Year of the Fire Chicken

January 5, 2017 - 5:00pm
Mike & Matt are joined by a gaggle of Lullabots to talk successes and failures of 2016, and what we're looking forward to in 2017.
Categories: Blogs

Mediacurrent: Migration with Custom Values in Drupal 8

January 5, 2017 - 9:39am
Custom Preprocessing

In Drupal 7 there were numerous ways to preprocess data prior to migrating values. This was especially useful when inconsistencies in the data source needed to be addressed. One example I have dealt with in the past was migrating email addresses from an old system that didn’t check for properly formatted emails on its user fields. These errors would produce faulty data in the new Drupal site. I preprocessed the field data for the most common mistakes which reduced the amount of erroneous addresses brought over.

Categories: Blogs

Liip: Drupal 8 Migrate Multilingual Content using Migrate API

January 5, 2017 - 6:24am

As a follow-up to my previous blog post about the usage of Migrate API in Drupal 8, I would like to give an example, how to import multilingual content and translations in Drupal 8.

Prepare and enable translation for your content type

Before you can start, you need to install the “Language” and “Content Translation” Module. Then head over to “admin/config/regional/content-language” and enable Entity Translation for the node type or the taxonomy you want to be able to translate.

As a starting point for setting up the migrate module, I recommend you my blog post mentioned above. To import data from a CVS file, you also need to install the migrate_source_csv module.

Prerequisites for migrating multilingual entities

Before you start, please check the requirements. You need at least Drupal 8.2 to import multilingual content. We need the destination option “translations”, which was added in a patch in Drupal 8.2. See the corresponding drupal.org issue here.

Example: Import multilingual taxonomy terms

Let’s do a simple example with taxonomy terms. First, create a vocabulary called “Event Types” (machine name: event_type).

Here is a simplified dataset:

Id Name Name_en 1 Kurs Course 2 Turnier Tournament

You may save this a csv file.

Id;Name;Name_en 1;Kurs;Course 2;Turnier;Tournament

The recipe to import multilingual content

As you can see in the example data,  it contains the base language (“German”) and also the translations (“English”) in the same file.

But here comes a word of warning:

Don’t try to import the term and its translation in one migration run. I am aware, that there are some workarounds with post import events, but these are hacks and you will run into troubles later.

The correct way of importing multilingual content, is to

  1. create a migration for the base language and import the terms / nodes. This will create the entities and its fields.
  2. Then, with an additional dependent migration for each translated language, you can then add the translations for the fields you want.

In short: You need a base migration and a migration for every language. Let’s try this out.

Taxonomy term base language config file

In my example, the base language is “German”. Therefore, we first create a migration configuration file for the base language:

This is a basic example in migrating a taxonomy term in my base language ‘de’.

Put the file into <yourmodule>/config/install/migrate.migration.event_type.yml and import the configuration using the drush commands explained in my previous blog post about Migration API.

id: event_type label: Event Types source: plugin: csv # Full path to the file. Is overriden in my plugin path: public://csv/data.csv # The number of rows at the beginning which are not data. header_row_count: 1 # These are the field names from the source file representing the key # uniquely identifying each node - they will be stored in the migration # map table as columns sourceid1, sourceid2, and sourceid3. keys: - Id ids: id: type: string destination: plugin: entity:taxonomy_term process: vid: plugin: default_value default_value: event_type name: source: Name language: 'de' langcode: plugin: default_value default_value: 'de' #Absolutely necessary if you don't want an error migration_dependencies: {}

Taxonomy term translation migration configuration file:

This is the example file for the English translation of the name field of the term.

Put the file into <yourmodule>/config/install/migrate.migration.event_type_en.yml and import the configuration using the drush commands explained in my previous blog post about Migration API.

id: event_type_en label: Event Types english source:   plugin: csv # Full path to the file. Is overriden in my plugin path: public://csv/data.csv # The number of rows at the beginning which are not data. header_row_count: 1 keys: - Id ids: id: type: string destination: plugin: entity:taxonomy_term translations: true process: vid: plugin: default_value default_value: event_type tid: plugin: migration source: id migration: event_type name: source: Name_en language: 'en' langcode: plugin: default_value default_value: 'en' #Absolutely necessary if you don't want an error migration_dependencies: required: - event_type

Explanation and sum up of the learnings

The key in the migrate configuration to import multilingual content are the following lines:

destination: plugin: entity:taxonomy_term translations: true

These configuration lines instruct the migrate module, that a translation should be created.

tid: plugin: migration source: id migration: event_type

This is the real secret. Using the process plugin migration,  we maintain the relationship between the node and its translation.The wiring via the tid field make sure, that Migrate API will not create a new term with a new term id. Instead, the existing term will be loaded and the translation of the migrated field will be added. And thats exactly what we need!

Now go ahead and try to create a working example based on my explanation. Happy Drupal migrations!

Categories: Blogs

Pages