Drupal Planet

Syndicate content
Drupal.org - aggregated feeds in category Planet Drupal
Updated: 13 weeks 6 days ago

lakshminp.com: Tagged services in Drupal 8

Wed, 2016-08-17 07:07

We saw how to write a simple service container in Drupal earlier. We shall build a tagged service now. To illustrate a proper use case for tagged services, let's contrive a scenario where you add a pipeline custom filters to user text before rendering it on the page.

First, clone the code which will be used in this post.

$ git clone git@github.com:drupal8book/process_text.git

Checkout the first version of the code where we take custom text from user, process and display it in a page without using services.

$ cd process_text $ git checkout -f just-filtering

We get custom text from a user using a config form.

class CustomTextSettingForm extends ConfigFormBase { /** * {@inheritdoc} */ protected function getEditableConfigNames() { return [ 'process_text.settings', ]; } /** * {@inheritdoc} */ public function getFormId() { return 'custom_text_setting_form'; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('process_text.settings'); $form['custom_text'] = [ '#type' => 'textarea', '#title' => $this->t('Custom Text'), '#default_value' => $config->get('custom_text'), ]; return parent::buildForm($form, $form_state); } /** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $this->config('process_text.settings') ->set('custom_text', $form_state->getValue('custom_text')) ->save(); $form_state->setRedirect('process_text.show'); } }

We save it as a piece of configuration called process_text.settings.custom_text.

Before rendering this text, let's say you would want to:

  • Remove any <div> tags.
  • Substitute a token [greeting] with <span class"greeting">hello world</span> throughout the text.

We get the text and do all the above processing inside a custom controller.

class ProcessTextController extends ControllerBase { /** * Processtext. * * @return string * Return processed custom text. */ public function processText() { $custom_text = \Drupal::config('process_text.settings')->get('custom_text'); // do processing // remove divs $custom_text = str_replace(["<div>", "</div>"], "", $custom_text); // replace greeting tokens $custom_text = str_replace("[greeting]", '<span class="greeting">hello world</span>', $custom_text); return [ '#type' => 'markup', '#markup' => $custom_text ]; } }

This is good, but we could do better. What if we change the filter applying mechanism? We have to change this code. Instead, let's convert it into a service.

$ cd process_text $ git checkout -f services-first-cut

Our text filter service takes a set of filters and applies them to a given text when we call applyFilters.

class TextFilterService { private $filters = []; /** * @param Filter $filter */ public function addFilter(Filter $filter) { $this->filters[] = $filter; } /** * applies all filters to given text and returns * filtered text. * * @param string $txt * * @return string */ public function applyFilters($txt) { foreach ($this->filters as $filter) { $txt = $filter->apply_filter($txt); } return $txt; } }

We need to crate a services.yml file for the above service.

services: process_text.text_filter: class: Drupal\process_text\TextFilterService

Here's how the processText function text looks now.

public function processText() { $custom_text = \Drupal::config('process_text.settings')->get('custom_text'); // do processing using a service $filter_service = \Drupal::service('process_text.text_filter'); // remove divs $filter_service->addFilter(new RemoveDivs()); // substitute greeting token $filter_service->addFilter(new Greeting()); // apply all the above filters $custom_text = $filter_service->applyFilters($custom_text); return [ '#type' => 'markup', '#markup' => $custom_text ]; }

Now the filter applying mechanism is swappable. We can add write a different functionality and inject that implementation using service containers.

Now, what if we want to add a new filter to this code, like, enclosing the whole text within a <p> tag.

Sure. We could do that.

Let's checkout the specific tag where we add a new filter.

$ cd process_text $ git checkout -f add-new-filter

We build that filter.

class EnclosePTags implements Filter { public function apply_filter($txt) { return '<p>'. $txt . '</p>'; } }

…and add it to the set of filters being applied.

public function processText() { $custom_text = \Drupal::config('process_text.settings')->get('custom_text'); // do processing using a service $filter_service = \Drupal::service('process_text.text_filter'); // remove divs $filter_service->addFilter(new RemoveDivs()); // substitute greeting token $filter_service->addFilter(new Greeting()); // Enclose p tags $filter_service->addFilter(new EnclosePTags()); // apply all the above filters $custom_text = $filter_service->applyFilters($custom_text); return [ '#type' => 'markup', '#markup' => $custom_text ]; }

How about injecting the filter adding mechanism itself? Wouldn't it be cool if we are able to add new filters without changing this part of the code? Not to mention the fact that the code will be more testable than before if we follow this approach. This is exactly what tagged services help us accomplish.

Let's write each filter as a tagged service.

$ cd process_text $ git checkout -f tagged-services

Here's how our process_text.services.yml looks now.

services: process_text.text_filter: class: Drupal\process_text\TextFilterService tags: - { name: service_collector, tag: text_filter, call: addFilter } remove_divs_filter: class: Drupal\process_text\TextFilter\RemoveDivs tags: - { name: text_filter } greeting_filter: class: Drupal\process_text\TextFilter\Greeting tags: - { name: text_filter } enclose_p_filter: class: Drupal\process_text\TextFilter\EnclosePTags tags: - { name: text_filter }

There are many changes here. Firstly, all the filters have been converted to services themselves. The have a common tag called text_filter. The main service also has a few changes. It has a tag called service_collector and a tag parameter call. This ritual of creating a service container and adding a set of tagged services is such a common pattern that Drupal 8 has a special tag to do this, called the service_collector. This tag takes an additional parameter called call which indicates what function has to be called in the service to add all the tagged services.

What happens is, Drupal's TaggedHandlersPass picks up all services with "service_collector" tag, finds services which have the same tag as that of this service(text_filter in our case) and calls the method in call to consume the tagged service definition. If you're coming from Symfony world, this might seem familiar for you. In order to execute some custom code, like applying a set of filters, we implement CompilerPassInterface, which is run whenever the service cotainer(ApplyFilter in our case) is being built. You can find more about CompilerPassInterface here.

Your controller code looks a lot simpler now.

public function processText() { $custom_text = \Drupal::config('process_text.settings')->get('custom_text'); // do processing using a service $filter_service = \Drupal::service('process_text.text_filter'); $custom_text = $filter_service->applyFilters($custom_text); return [ '#type' => 'markup', '#markup' => $custom_text ]; }

Now, all you need to add new filters is to update the service yaml file with the new filter service and tag it with "text_filter" tag.

Tagged services in the wild

Drupal allows developers to add a new authentication mechanism using tagged services. The authentication_collector is defined in core.services.yml.

authentication_collector: class: Drupal\Core\Authentication\AuthenticationCollector tags: - { name: service_collector, tag: authentication_provider, call: addProvider }

To add a new authentication provider, one has to implement the AuthenticationProviderInterface and flesh out the applies and authenticate functions. This will be the subject of another post.

Here's how the addProvider function looks like:

public function addProvider(AuthenticationProviderInterface $provider, $provider_id, $priority = 0, $global = FALSE) { $this->providers[$provider_id] = $provider; $this->providerOrders[$priority][$provider_id] = $provider; // Force the providers to be re-sorted. $this->sortedProviders = NULL; if ($global) { $this->globalProviders[$provider_id] = TRUE; } }

And here's how we would register our hypothetical authentication provider service.

services: authentication.custom_auth: class: Drupal\custom_auth\Authentication\Provider\CustomAuth tags: - { name: authentication_provider }

Another example is the breadcrumb manager service.

breadcrumb: class: Drupal\Core\Breadcrumb\BreadcrumbManager arguments: ['@module_handler'] tags: - { name: service_collector, tag: breadcrumb_builder, call: addBuilder }

To add breadcrumbs from your module, you would need to implement BreadcrumbBuilderInterface and add the following entry to your services.yml,

services: foo.breadcrumb: class: Drupal\foo\MyBreadcrumbBuilder tags: - { name: breadcrumb_builder, priority: 100 }

The BreadcrumbManager::addBuilder collects all breadcrumb bilders and builds it using the BreadcrumbManager::build function.

public function addBuilder(BreadcrumbBuilderInterface $builder, $priority) { $this->builders[$priority][] = $builder; // Force the builders to be re-sorted. $this->sortedBuilders = NULL; } Drupal, Drupal 8, Drupal Planet
Categories: Drupal

Lullabot: Making Web Accessibility Great Again: Auditing the US Presidential Candidates Websites for Accessibility

Wed, 2016-08-17 06:00

Imagine that you arrive at a website, but you cannot see the screen. How do you know what’s there? How do you navigate? This is normal for many people, and the accessibility of your site will make or break their experience. Accessibility is about including everyone. People with physical and cognitive disabilities have specific challenges online—and making your site accessible removes those barriers and opens the door to more users.

Severely disabled Americans constitute a population of 38.3 million people, and make up a huge swath of voters (see the #CripTheVote movement on Twitter). Some notable U.S. presidential elections have been decided by much less, and because of this, we’re auditing the US presidential election candidates’ websites.

During this audit, we’ll see what the candidates’ websites are doing right and wrong, and where the low-hanging fruit lies. This article won’t be a full top-to-bottom audit, but we will show some of the important things to look for and explain why they’re important.

Our Methods Automated Testing

The first step in our a11y audit is to do a quick automated check. If you’re new to accessibility, the WAVE tool by WebAIM is a great place to start. It’ll check for standard accessibility features and errors in alt attributes, contrast, document outline, and form labels. For the features or errors it finds, it provides an info icon that you can click to learn what the issue is, why it’s important, and how to do it right. WAVE is free, and highlights both negative (errors, alerts, features, structural elements, ARIA attributes, contrast), and positive (features, structural elements, ARIA attributes).

Keyboard Testing

As great as WAVE is, an automated tool is never as good as a live person. This is because some accessibility requirements need human logic to apply them properly. For the next part, we’re going to navigate around each website using only the keyboard.

This is done by using the tab button to move to the next element, and shift-tab to move backwards. The spacebar (or return) is used to click or submit a form element. If everything is done right, a person will be able to navigate through your website without falling into tab rabbit-holes (tabbit-holes?). We should be able to tab through the whole page in a logical order without getting stuck or finding things that we can’t access or interact with.

Beyond that, we need to be able to see where the focus lies as we tab across the page. Just as interactive elements give a visual cue on hover, we should get an indication when we land on an interactive element while tabbing, too. That state is referred to as ‘having focus’. You can extend your hover state to focus, or you can make a whole new interaction for focus. It’s up to you!

.link--cta-button:hover, .link--cta-button:focus { /* The :focus pseudo-class for a11y */ background: #2284c0; } Screen Reader Audit

Screen readers are used by visually impaired and blind people to navigate websites. For this purpose we’ll use VoiceOver, which is the default pre-installed screen reader for OS X. We’re looking for things that read oddly (like an acronym), things that don’t get read that should get read (and vice-versa), and making sure all of the information is available.

Let’s start with Donald Trump’s website

The first thing that we did while looking at Donald Trump’s website was audit it using the WAVE tool. Here’s what we found:

  • 8 Errors
  • 14 Alerts
  • 15 Features
  • 35 Structural Elements
  • 5 HTML5 and ARIA
  • 5 Contrast Errors (2 were false flags)
The Good Bold Colors for a Bold Candidate

The color scheme is very accessible. On the front page, there were only two places where the contrast wasn’t sufficient. Outside of that, his color scheme provides text that stands out well from the background and is easy to read for low-vision users.

The Bad Lacking Focus

Remember how we talked about focus states? This site has almost none. Tabbing through the page is confusing because there are no visual indications of where you are.

This is especially egregious because the browser automatically applies focus states to focusable elements for you. In order for there not to be focus elements at all, the developer has to actively go out of their way to break them by applying outline: 0; to the element’s focus state. This is okay if you’re doing it to replace the focus state with something more decorative, but taking it off and not replacing it is a big accessibility no-no.

Skipped Skip Link

When tabbing through The Donald’s website, the first thing we notice is the absence of a skip link. Without a skip link, a keyboard user is forced to tab through each link in the navigation when arriving at each page before they can access the rest of the content. This repetitive task can become aggravating quickly, especially on sites with a lot of navigation links.

Unclear Link Text

Links should always have text that clearly explains where the user is going. The link’s text is what a person using a screen reader will hear, so text like ‘Read More’ or text and icons that require visual context to understand their destination aren’t ideal.

In this area, the link text that goes out to the linked Twitter posts read ‘12h’ and ‘13h’. Without the visual context of a Twitter icon (that’s a background image, so there’s no alternative text to provide that), the user probably has no idea what ‘12h’ is referring to or where that link will lead.

The Ugly Navigation Nightmares

The most important part of any website, in terms of access, is the navigation. An inaccessible navigation menu can block access to large portions of the website. Unfortunately, the navigation system of Trump’s website does just that, and prevents users with disabilities from directly accessing the sub-navigation items under the issues and media sections.

A more accessible way to do this is to use a click dropdown instead of a :hover. If that doesn’t work for the design, make sure that the :hover state of the menu applies to :focus as well, so that the menu will open the nested links when the parent menu item is tabbed to.

Disorganized Structure

Structural elements (h1, h2, h3, etc tags) are very helpful when used properly. In this case, they’re definitely not. Heading levels aren’t sequential, and nested information isn’t always relevant to its parent.

Audit of Hillary Clinton’s website The Good

Overall, Clinton’s website is better than most when it comes to accessibility. It’s that clear that her development team made it a purposeful consideration during the development process. While it’s not perfect, there was a lot of good done here. Let’s explore some examples of things done right.

Keyboard Accessibility

The keyboard accessibility on this site is very good. We found that we could access the elements and navigate to other pages easily without a mouse. It was easy to open and shut the drop-down ‘More’ area in the navigation, and access its nested links, which is a good example of how to implement what we were talking about when we covered the shortfalls of the navigation system on Trump’s website.

Skip Link

Hillary Clinton’s website includes a proper skip link, which allows users to skip the navigation and go directly to the content.

Great Focus States

The other thing we found when checking the keyboard accessibility was that everything has a focus state that makes it visually obvious where you are on the page. The light dotted border focus state is a bit subtle for low-vision users, but the fact that the focus state of the elements was styled independently from the hover state shows that the developer was aware of the need for focus indicators and made a conscious effort to implement them.

Translation

We usually think of accessibility in terms of people with disabilities because they often benefit from it the most, but accessibility is really just about including as many people as possible. A nice touch we found on Clinton’s site was a button at the top to translate the site into Spanish. With 41 million native Spanish speakers in the US, providing the option to experience the content in the user’s first language is a great accessibility move.

Video Captioning

Deaf people rely on captions to get the dialogue from videos, since it’s very difficult to lip-read in film. The videos on Hillary’s site are furnished with open captions, which means that they’re always on. Open captions are great for people with disabilities, but they’re also a smart move to capture your non-disabled audience as well. Often autoplay videos won’t play any sound unless they’re interacted with, but providing open captions on the video gives you another chance to capture the audience’s interest by displaying the words on the screen.

The Bad No Transcripts for Video

While it was great that the videos were captioned, we couldn’t find a transcript provided. Many people erroneously believe that you only need one or the other, but captions and transcripts actually serve different purposes, so it’s ideal to provide both. Captions are great for the Deaf, who want to read the words in real-time with the video. Transcripts are more useful for the blind and the Deaf-blind, who benefit from a written summary of what’s visually happening onscreen in each scene before the written dialogue begins. A braille terminal, used by the Deaf-blind, can’t convert open captions inlaid into the video’s frames into braille for its users, so these users won’t benefit from that.

Low Contrast

Contrast is important for low-vision users. We know that subtlety is all the rage, but design choices like putting blue text on a blue background makes it really difficult for some people to read. There are some great free tools like Das Plankton that will let you see if your contrast level is high enough to meet accessibility standards.

Schemes like this fail contrast testing on every level, so it’s best to avoid them. A better choice probably would have been white over a slightly darker blue.

The Ugly The Horrible Modal

Despite the obvious hard work that went into making Hillary’s website accessible, much of the effort is lost due to a modal that appears when visiting the website for the first time (or in incognito mode). The problem is that the modal doesn’t receive focus when it pops up, and its close button has no focus indicator. While it technically can be closed via keyboard by navigating backwards (or tabbing through every single link on the page) once it pops up, it’s not obvious visually when that close button has focus, and navigating backwards isn’t exactly intuitive.

Conclusion

With one glaring exception, it’s obvious that lots of thought and work had been put into making Hillary Clinton’s website accessible to voters with disabilities. There is definitely room for improvement with small things like somewhat irrelevant alternative attributes on photos, but on the whole the site is better on accessibility than the vast majority of the sites that we see.

Unfortunately, it is also obvious that accessibility is deeply neglected within Donald Trump’s website, which leaves a large swath of potential voters unable to browse to his stance on issues and other content. Hopefully, this will be attended to shortly.

Hopefully these auditing case studies lead you to think about your own website from the point of view of a person with a disability. There are plenty of challenges online for the disability community, but lots of those can be fixed with a few easy tweaks like the ones we covered here. We hope you'll use what you've learned to make your website accessible, too.

Categories: Drupal

Anexus: How to use ES6 in Drupal 8

Wed, 2016-08-17 03:58
How to use ES6 in Drupal 8

I bet many of you doesn't understand what is ES6, being honest I didn't know this term until a few days ago. 

ES6 stands for ECMAScript v6 or ES2015, but in simple words, is just Javascript; Correct Javascript as simple as that.

So, ES6 one of the latest version of Javascript specification, but is not supported by all browsers, because was released in June 2015, even worst in June 2016 we got ES7 and as you can imagine not supported yet.

Right now all browsers support ES5, then, if it's not compatible with all browsers, why ES6+ is a big thing? Because, now Javascript is more OOP, using classes, constants, and modules, enabling to create more complex and organized projects.

So, how we could use ES6 in our web projects like Drupal, to avoid to have a particular version of our site based on our client's browser? The solution is Babel

Babel transforms your code to ES5 to be used in your web applications. 

Babel works using plugins that allow the transformation and enable to use a particular plugin based on the source of your code like React that requires an especial plugin to do the conversion.

Let me show an example that creates a simple ReactJS.

1. Install Node.js

The first thing we need to do is install Node.js in your system, the easy way to do that is downloading the proper installer for our platform from https://nodejs.org/en/download

We need to install Node.js because we are going to use the NPM which is a package manager for javascript libraries 

2.  Modify gitignore file

Drupal 8 projects include their own .gitignore file, but because we are about to include npm in our development process, we need to add some extra rules listed below:

# Node.js # Logs logs *.log npm-debug.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules jspm_packages # Optional npm cache directory .npm # Optional REPL history .node_repl_history
3. Create a package.json file

To be able to distribute later your javascript library you need to create a package.json file, you create that file in interactive mode using the command:

$ npm init

In the end, you will get a file similar to the following file.

{   "name": "drupalreactform",   "version": "1.0.0",   "description": "ReactJS form to be embed in Drupal 8 Controller",   "main": "index.js",   "scripts": {     "test": "echo \"Error: no test specified\" && exit 1"   }   "author": "enzo - Eduardo Garcia",   "license": "ISC" } 4. Install Webpack

To expose our library in Drupal we need to create a distribution package, for that purpose, we will use [Webpack](webpack.github.io) that is a module bundler which takes modules with dependencies to generates static assets by bundling them together.

$ npm install webpack --save

The command about will install webpack with all required libraries and modify our package.json, in the same way that we use in Composer the composer.json file.

5. Configuring Webpack & creating bundle

It's necessary to inform to Webpack using file webpack.config.js, how we can to create our bundle to be used Drupal, the following configuration assumes we have a custom module located in web/modules/custom/mysearch.

var webpack = require('webpack'); var path = require('path'); var MODULE_BUILD_DIR = path.resolve(__dirname, 'web/modules/custom/mysearch/js'); var MODULE_APP_DIR = path.resolve(__dirname, 'web/modules/custom/mysearch/js/es6'); var config = {   entry: MODULE_APP_DIR + '/mysearch.form.jsx',   output: {     path: MODULE_BUILD_DIR,     filename: 'mysearch.form.js'   } }; module.exports = config;

With the configuration above, we are saying we will load the file mysearch.form.jsx and all included files in mysearch.form.js file

If you write something simple like

console.log('Hello ES6!');

You don't need any special transformation and you can create the bundle, for that propose you need to execute the following command:

$ ./node_modules/.bin/webpack -d

You will get an output similar to this image:

The generation will work correctly because the source in ES5 and the output too; So, no transformation was required.

6. Testing transformation

I know I said we would embed the file generated in Drupal, but in a development process is faster if we could test first outside Drupal, for that, we could create a file named test/es62es5/index.htm inside module directory  with the following content.

          Testing transformation ES6 -> ES5              

Opening that file in our browser would enable any possible error and reduce the change to blame Drupal 8 for a malfunction in our code.

7. Use Babel to transform ES6

Now we need to install Babel and Babel loaders to be able to transform our ReactJS form into ES5; the next command installs the required packages.

$ npm install babel-loader babel-preset-es2015 babel-preset-react --save

Also, we need to create a .babelrc file, to inform to Babel what presents will be used in transformation, check and example of that file below:

{   "presets" : ["es2015", "react"] }

Finally, we need to modify out webpack configuration to report what loader we are going to use in our transformation, the new aspect of webpack.config.js will be like this:

var webpack = require('webpack'); var path = require('path'); var MODULE_BUILD_DIR = path.resolve(__dirname, 'web/modules/custom/mysearch/js'); var MODULE_APP_DIR = path.resolve(__dirname, 'web/modules/custom/mysearch/js/es6'); var config = {     entry: MODULE_APP_DIR + '/mysearch.form.jsx',     output: {         path: MODULE_BUILD_DIR,         filename: 'mysearch.form.js'     },     module : {         loaders : [             {                 test : /\.jsx?/,                 include : MODULE_APP_DIR,                 loader : 'babel'             }         ]     } }; 8. Create React form

Before to create the form we need to install some libraries to build our form.

$ npm install react react-dom antd --save

If we plan to embed CSS or LESS files in our app, need to install loaders for that using the following instructions, and register the loader in webpack

$ npm install css-loader less less-loader style-loader  --save-dev

The code of our form will be an example form React created in a previous blog post:

import React, { PropTypes } from 'react'; var Search = React.createClass({     render: function(){         return (             React.createElement('form', {onSubmit: this.onSubmit, className: 'SearchForm', noValidate: true},                 React.createElement('input', {                     type: 'text',                     placeholder: 'Search'                 }),                 React.createElement("select", { placeholder: 'Category', value: '', onChange: this.changeHandler },                     React.createElement("option", { value: 1 }, "Software"),                     React.createElement("option", { value: 2 }, "Movie")                 ),                 React.createElement('button', {type: 'submit'}, "Go")             )         );     }, }); ReactDOM.render(React.createElement(Search),  document.getElementById("app"));

Of course, you can create a more advanced form, importing other libraries.

9. Include form in a Drupal controller

After "compile" our form in one file, the remaining step is to include it in a Drupal Controller, to do that you just need to follow the blog entry www.anexusit.com/blog/how-to-load-js-and-css-libraries-a-drupal-8-controller.

I hope did you find this blog entry useful.
 

enzo Wed, 08/17/2016 - 04:58
Categories: Drupal

Liip: Drupalaton 2016

Wed, 2016-08-17 02:13

Last week Drupalaton 2016 took place. With about 150 registrations this was the largest Drupalaton so far. The organizers did an amazing job in coping with this mass. There were two session threads and a sprint room. Of the many interesting presentations I would like to mention Fabian Bircher’s “Configuration Management: theory and practice” (a must for everyone who gets lost while trying to work in a team on a Drupal8 project) , Pieter Frenssen’s “Working with REST APIs”  (it was good to see how simple it is in Drupal8) and “Drupal 8 Media” from Pónya Péter, Szanyi Tamás and Rubén Teijeiro (seems we have a huge step forward in media handling since Drupal7!). I held a session on caching in Drupal 8 which was the shortened version the one I did on Drupal Developer Days in Milan.

Liip was a silver sponsor of the event.

Finally, some pictures on the Friday ship cruise. Thanks to Brainsum for sponsoring it!

Categories: Drupal

DrupalCon News: Build your DrupalCon agenda: the session and BOF schedule is live

Tue, 2016-08-16 20:00

DrupalCon starts in just 40 days. But you can plan your schedule today. There'll be more than 140 sessions, three keynotes, and one unforgettable pre-note.

Categories: Drupal

Anchal: GSoC'16 - Port Comment Alter Module - Week 12

Tue, 2016-08-16 17:00

As part of GSoC’16 I’m working on Porting Comment Alter module to Drupal 8 under the mentorship of boobaa and czigor. This blog is an excerpt of the work which I did in the twelfth week of the coding period of GSoC’16. The blogpost for the work done in the eleventh week can be found here.

The GSoC coding period ends this week and I’m glad that I was able to complete the project as per my proposal. All these three months have been very productive for me during which I learned a ton of things not just related to Drupal but also things like writing blogs, managing the project, etc.

During the coding period being stuck on a problem for 3-4 days and after countless hours of debugging finding the solution to be a one-liner or getting good reviews from mentors were some of the most intriguing and satisfying moments for me. I would like to thank both of my mentors boobaa and czigor for always helping me with coding, blogs and project management. It would have never been possible without them. I would also like to thank the whole Drupal community and Google Summer of Code for providing this opportunity to me.

Now talking about the work which I did this week, since most of the coding part was completed last week this week I focused on adding documentation for the module, doing cleaning and proof reading of the whole repo. I’ve created a short demo video: Comment Alter module for Drupal 8 demonstrating a simple use case and working of the module.


This week I also fixed some minor issues like changing the #parent property for the comment form for all the fields to avoid any clashes. In order to allow same name fields on both comment as well as parent entity the #parent property was used in the comment_alter_form_comment_form_alter() function. Due to this the submitted field values appeared at a different location preventing instances of multiple field value in the same #parent space or $form element (see commit).

In the upcoming week I would first move the module to drupal.org and will update the description about the module on the project page. I planned to move the module to drupal.org last week only but because of some complications, my mentors were unable to do the final review of the module. My mentors will do with the review before this Friday so I’ll move the module to drupal.org by then.

By the end of the week I’ve created a demo video for the module and fixed some issues. My mentors have already reviewed the code for the work which I did during this week. If anyone is interested, my progress can be followed on my GitHub repo.

Categories: Drupal

OSTraining: Would You Be Interested in an Online Drupal 8 Day?

Tue, 2016-08-16 11:59

Drupal 8 has been out since November and is now maturing into a really powerful platform.

We'd like to hold an online event all about Drupal 8. 

The event will be called "Drupal 8 Day" and will be an online version of a Drupal Camp.

It will be one complete day of live presentations. To get a good feel for this type of event, check out Wordsesh.org in the WordPress space.

The goal is to present Drupal 8 in the best possible light, especially to people who normally can't attend a Drupal Camp. We talk with a lot of people who just don't live near any kind of DrupalCamp. Some typical examples are people outside the big Canadian cities, people living in Eastern Europe but outside capital cities, and people in sub-Saharan Africa.

Categories: Drupal

frobiovox.com: Basic Hello World with composer and php

Tue, 2016-08-16 10:40
Getting started with composer I want this to be an introduction to using Composer. If you are looking for more information about using Drupal with Composer then you should checkout the official composer facade doc page on drupal.org. I will not be talking about publishing to Packagist. My php is nearly always for Drupal, and as such, if I publish anything it will most likely be to a project on...
Categories: Drupal

Galaxy: GSoC’ 16: Port Search Configuration module; coding week #12

Tue, 2016-08-16 10:14

Google Summer of Code' 16 coding phase has almost come to an end. The link for the final submissions will be open from 16-23 August 2016. I am sure all the students and mentors had a memorable time learning new technologies, sharing their ideas and giving shape for the proposals submitted to the organisations in the initial phase. Now ,its time for the works to get evaluated.

As you know, I was engaged with porting search configuration module to Drupal 8.The past week I devoted for documentation of the ported module, writing few tests for the module and then fixing some of the issues reported/ I came across in the testing time. The collapsible elements were not active. It had to be ported to the HTML5 elements. This was an important fix that I could achieve in the past week. So, I will help you understand what this actually is.
In Drupal 7, to make the field-sets collapsible, we had to set the collapsible attribute as true.

$form[‘settings’] = array(
‘#type’ = ‘fieldset’,
‘#title’ = t(‘Search Configuration’),
‘#collapsible’ => TRUE,
‘#collapsed’ => TRUE,
);

In Drupal 8, we make use of the HTML5 details and the open elements to achieve this collapsible state for the field-sets. I.e,

$form[‘settings’] = array(
‘#type’ = ‘details’,
‘#title’ = t(‘Search Configuration’),
‘#open’ => TRUE,
);

This was one important task that was left behind. I should have done it before. So, now the collapsible issue is fixed for now. Now, I need to spend some time for the testing the module documentation.

Another issue that I had to fix was the removal of the !placeholders. The !placeholder has been removed from the t() and the format_string() of Drupal 8. This has been moved to :variable format.
<.a href = “:variable”>@variable

Documentation is always an important process when it comes to any software development. We need to document the functionalities available and the various functions added to the module so that it will be beneficial for users as a future reference. I found time to document the important functions involved. I am sure this is really an essential component for developers who would like to contribute to this module. I have documented mainly the helper functions which have been used in the module.

I was mentored by Karthik Kumar, Naveen Valecha and Neetu Morwani. They stood along with me for any sort of help and helped me a lot to improve my basic skills in Drupal. Thanks to all of you for the support and co- operations. I am also thankful to Alan for his tips and suggestions even in his very busy schedules. He was also very much helpful in reviewing some of the patches for some of the issues reported. I can never forget the contribution of our organisation admin- Slurpee in the progress of my project. The weekly analysis of the project and the blog posts on the status updates have really benefitted me. I would also like to extend my sincere thanks to all the other community members for supporting me and guiding me in this long process. I really enjoyed this project development process. I could learn a lot and I want to stay connected with the Drupal community contributing to various projects and help the members of the community. It is really a proud moment to see our commits being reviewed by experienced developers. Moreover, the support from the community members was really exciting. People were ready to share ideas and help whenever I was stuck in the implementation process. I would also thank Google for bringing up a platform for university students to work on some of the high quality projects of the open source organisations.

Tags: drupal-planet
Categories: Drupal

Hook 42: Node.js version control in Drupal themes

Mon, 2016-07-18 12:44

It is important that for any given project, each developer uses the same version of Node.js and related Javascript (JS) packages. In this article, we’ll discuss how to use “Node Version Manager” (NVM) to install multiple versions of Node.js, how to use “Automatic Version Switching for Node.js” (AVN) to automatically switch Node.js versions when changing to a project directory, and how to use “Node Package Manager” (NPM) to keep track of JS packages.

Categories: Drupal

FFW Agency: The ABC's of Drupal: Component, Composer, Console

Mon, 2016-07-18 11:15
The ABC's of Drupal: Component, Composer, Console Ray Saltini Mon, 07/18/2016 - 18:15

When we said we'd introduce you to the ABC's of Drupal we didn't just mean the easy stuff. Here are three C's that will help you understand the power behind Drupal 8.

Component: In Drupal 8 the word component is often used to identify one of the libraries managed by the Symfony project used by Drupal. Visit this link for a full list. https://ffwagency.com/blog/what-symfony-components-are-going-into-drupal-8 While Twig is often cited as a Symfony component, strictly speaking it is a PHP theming engine created by the same individuals who founded and maintain the Symfony project.

Composer: Composer is a dependency manager tool for PHP, Drupal’s core scripting language. If you are familiar with a package manager it is similar but not the same. Practically speaking Composer will help you download, install and manage specific code libraries and any additional code libraries they in turn may be dependent on for a given project. It’s important to understand that Composer is project centric - it defaults to managing code and dependencies within projects (like websites) rather than globally across projects. Composer’s use in the Drupal space is growing with the adoption of Drupal 8 and has begun to be used as an alternative to .make files which have been used to help manage Drupal installs and distributions.

Console: Console is a component of the Symfony project. Most often when a Drupal developer refers to using Console they are talking about using Drupal Console, a suite of tools run from a command line interface (CLI) to generate boilerplate code and interact with a Drupal 8 installation. In 2014 FFW hired Drupal Console’s lead project developer Jesus Olivas to develop the project and contribute the tool back to the Drupal community to strengthen Drupal 8 adoption. Drupal Console is used as a learning tool, module and theming scaffolding, debugger and configuration tool for Drupal 8. For more information on Drupal console visit https://ffwagency.com/blog/drupal-console-an-overview-of-new-drupal-cli

Tagged with Comments
Categories: Drupal

Appnovation Technologies: Giving Back with Drupal: Isa Mundo Foundation

Mon, 2016-07-18 10:44
Drupal is used by nonprofits around the world because it provides a low-cost, flexible and scalable platform for any kind of organization.
Categories: Drupal

Jeff Geerling's Blog: Migrating Link fields with multiple properties with Drupal 8

Mon, 2016-07-18 10:11

Today I needed to migrate a URL/Link into a Drupal 8 site, and I was scratching my head over how to migrate it so there were distinct values for the URL (the actual link) and the Label (the 'title' that displays to end users and is clickable). Drupal 8's Link field type allows you to set a URL in addition to an optional (or required) label, but by default, if you just migrate the URL, the label will be blank.

I first set up the migration config like so:

...
process:
  field_url: source_url

And source_url was defined in the migration's source.fields configuration.

In my case, the source data didn't have a label, but I wanted to set a default label so the Drupal 8 site could display that as the clickable link (instead of an ugly long URL). To do that, it's similar to migrating a formatted text field, where you can migrate individual components of the field using the syntax [field_name]/[component]. In a Link field's case, it looks like:

Categories: Drupal

Ben's SEO Blog: 8 Ways Drupal 8 Can Improve Your Website and Generate More Leads

Mon, 2016-07-18 09:00

Drupal 8 is a marketer’s dream. With the new core enhancements, you can execute more effective marketing campaigns because you can deliver personalized content segmented by audience, language, and device type. You can develop relevant content that improves SEO, drives users to your website, creates leads, and results in more sales.

Drupal draws on the innovation of thousands of developers, designers, and marketers who contribute to the open-source platform. The result is that cutting-edge, marketing functionality is now included in the core of Drupal 8.

1.  Mobile For Your Customers; Mobile for You

Most platforms today offer some form of mobile responsiveness. While this was an add-on for Drupal 7, it’s now built into Drupal 8’s core functionality. Mobile-responsiveness is critical for Google rankings and it’s key to marketing success. We’ve seen it coming. As more and more people began to use smartphones for everything in their personal lives, it was inevitable that it would drive mobile usage in the business world as well. While consumer marketing was at the forefront of mobile marketing, B2B mobile marketing has expanded as well. Google reports 300% growth in B2B queries in just two years. Mobile isn’t a trend anymore; it’s a necessity.

The newest version of Drupal takes mobility seriously. All of Drupal 8’s built-in themes are mobile-responsive. Web services are built into the core of Drupal 8, allowing content to be accessed from any device such as Amazon’s Alexa. Now that Apple has opened Siri to third party developers, it is only a matter of time before Drupal will be powering Siri’s voice-based interactions.

And mobile is not just for your website visitors. Drupal has taken the next step and optimized website administration for mobile. You can administrate, create and publish content, approve editorial changes, clear caches, or any other admin task all on your mobile device.

2. The Path From Everyone to Each One--Personalized Content is Now in Drupal 8

Personalized content is needed to be competitive and Drupal 8 provides tools to help you achieve it. Customers are coming to expect streamlined, end-to-end, digital experiences and the companies who fail to provide this are increasingly at a competitive disadvantage. While nearly all marketers see the need for personalization, getting there is another story. Only 4% of marketers consider their web site to be very personalized and most of them don’t know how to achieve it. Often, technology can be a roadblock to achieving higher levels of engagement at every customer touch point.

Drupal 8 can help you quickly deploy various types of digital content and campaigns that span multiple segments and channels. It allows you to define customer segments, create custom content and deliver it in real-time on any device.

3. Speed Matters. Stay in Front of the Race

According to the Aberdeen Group, customers are won or lost in one second. Nearly half of web users expect a site to load in 2 seconds or less and they tend to abandon a site that isn’t loaded within 3 seconds. This means if your website is slow, you’re losing conversions from visitors on your site. A second delay in page response can result in a 7% reduction in conversions. The fact is, faster pages make more money.

The speed of your page loading matters to the user and that means it matters for SEO as well. Google uses page load time as one factor to determine rankings, so optimizing your page load time is important. This will give your website an extra edge on the competition and a boost in rankings.

Drupal 8 has features that make your websites faster without the need for a lot of technical expertise. Drupal 8 uses “cache tags” that makes caching more efficient and includes Cache Context API which provides context-based caching. This means pages load faster while ensuring that visitors always see the latest version of your site.

Also built into Drupal core is the BigPipe module. This new feature in Drupal 8 helps you deliver personalized content with the fastest page load time possible. BigPipe determines what parts of your web page are static and sends that instantaneously. The dynamic portion of your page--the parts that are personalized--are sent next. The net result is a much faster experience for your website visitors.

4. Need Multiple Languages? No Problema

Global business has become a strong driver in many companies’ revenue growth. Much of the economic growth is happening in countries like China and India, who have growing middle classes, meaning that if you want to take advantage of the global economy, you need to market to these countries as well. And it’s not just mega companies going overseas; 97% of U.S. exporters of goods are small businesses. The Internet has been the driver in opening up these global markets for goods and services. Through the Internet, even small businesses can target individual consumers in countries around the world. Companies that deliver web-based products and services tend to experience turbocharged global growth.

But all of this increases the complexity of your business: now you must deal with different languages, different customs and different distribution channels. In order to grow successfully, marketing teams must learn to tackle the global marketplace. They need to put the customer first no matter where that customer is located. Serving them well enables you to attract customers in other markets and turn them into referrals.

Drupal 8 has stepped up to the challenge of supporting a global presence. While many users face difficulty with languages and translations in Drupal 7, multilingual support is a part of the Drupal 8 core. With this version of Drupal, you are able to integrate a language much more easily and create territory-specific content. Not only can you change the back-end administration into another language, you can use Drupal’s language translator to translate links, pages and titles. When users visit your website they can select a language from those that you chose to provide. !Qué bueno!

5. Simplified Content Creation and Management

As digital content has gained massive importance in most businesses, the ability to easily create and manage content has become more important as well. IT resources are limited in any company and they need to be used wisely. The sooner you can put new content into place, the sooner you can react to changes or problems and the faster you can put new leads into your system.

One of the most exciting improvements in Drupal 8 is the addition of a WYSIWYG editor. With its drag-and-drop interface, you can edit content directly on the page rather than navigating to another. There are many options for image size, shape and alignment. You can also see how those images will look on a mobile device.

Many of the popular Drupal add-on modules have been included in the Drupal 8 core, meaning that less work and customization is needed to get the website you desire. Some of the modules new to Drupal core are Views, Block, and Context. One of the most exciting additions to Drupal 8 core is the Views module which provides great flexibility by enabling you to display any content in whatever format you require.

In addition to simplified content creation, Drupal 8 offers simplified management. You are able to monitor your website and your campaigns on your smartphone. When you are able to track your campaigns and see what is trending from content, social, and email efforts, anywhere and anytime, you can react quickly to market trends and customer requests.

6. Integrate, Don’t Re-create Data

Have you ever lost leads in the cracks between your various software systems? Drupal 8 integrates with email, analytics, marketing automation, CRM and other business software to create a seamless transition from content to lead generation to sale.

Drupal 8 offers a big upgrade in usability and often requires less technical understanding to complete integrations with third party systems. Marketers can frequently achieve integrations using community-built modules without coding knowledge.

7. Drupal 8: Proven and Tested  by Thousands

As with any software update, you want to know that the software has been well-tested and proven to work. In fact, tens of thousands of organizations are using Drupal 8 after less than a year on the market. Drupal 8 has more than 75,000 installations since its release in November. At this rate, it is being adopted twice as fast as the popular Drupal 7.

Memorial Sloan Kettering Cancer Center (MSK) used Drupal 8 beta version to launch its new website, mskcc.org in May, 2015, even when the software was still in its beta phase. Learn about other companies who use Drupal 8 at https://www.drupal.com/showcases.

8. SEO that is Sophisticated and Powerful

Drupal has always been one of the best content management systems for effective SEO results.  Drupal’s Taxonomy system automatically creates a page for tags that are optimized for search engines by adding the page to the XML Sitemap and updating it when changes are made. The updated XML sitemap can help search engines find the new content.

With its mobile-responsiveness and speed, Drupal 8 should provide even more assistance in achieving top Google rankings. There have always been a wide range of Drupal SEO modules that can further enhance your SEO efforts.. For Drupal 8, many of these SEO modules are still in testing.

Upgrading to Drupal 8 could create issues for your Google rankings if you don’t plan carefully. Taking SEO into account before the migration can save money. In a migration plan, all the web site’s current content and digital assets should be inventoried and a matrix of old to new should be created. Naming conventions for categories, link URLs, and anchor text should be considered and 301 redirects put in place if needed.

If you don’t have in-house staff to manage the process, you may want to consider hiring an experienced Drupal SEO expert. There is no avoiding an effect in search visibility 100%, however, if the SEO expert is involved from the start, key insights can be incorporated into the overall process, mitigating ill effects such as short term costs for redeveloping CMS and long term effects from uncrawlable content, lost links and lost traffic.

Ready to Make the Switch to Drupal 8?

If you are ready to migrate to Drupal 8, Volacci can provide a Drupal SEO migration audit so that you can make the switch with confidence. Give us a call at (512) 989-2945.

drupal marketing, drupal seo, Planet Drupal, drupal 8
Categories: Drupal

Acquia Developer Center Blog: Drupal 8 Module of the Week: Permissions by Term

Mon, 2016-07-18 08:20

Each day, between migrations and new projects, more and more features are becoming available for Drupal 8, the Drupal community’s latest major release. In this series, the Acquia Developer Center is profiling some prominent, useful, and interesting projects available for Drupal 8--modules, themes, distros, and more! This week: Permissions by Term.

Tags: acquia drupal planetaccess controlgroupogorganic groups
Categories: Drupal

OSTraining: How to Install Drupal 7 Using Bitnami for Windows

Mon, 2016-07-18 07:05

Bitnami is a software that allows you to install website applications such as Joomla, WordPress and of course Drupal 7.

In this tutorial we will show you how to install Bitnami on Windows to create a Drupal 7 site.

Categories: Drupal

Drupal Blog: Drupal 8.1.7 released

Mon, 2016-07-18 07:00

Drupal 8.1.7, a maintenance release which contains fixes for security vulnerabilities, is now available for download.

See the Drupal 8.1.7 release notes for further information.

Download Drupal 8.1.7

Upgrading your existing Drupal 8 sites is strongly recommended. There are no new features nor non-security-related bug fixes in this release. For more information about the Drupal 8.1.x release series, consult the Drupal 8 overview.

Security information

We have a security announcement mailing list and a history of all security advisories, as well as an RSS feed with the most recent security advisories. We strongly advise Drupal administrators to sign up for the list.

Drupal 8 includes the built-in Update Manager module, which informs you about important updates to your modules and themes.

Bug reports

Drupal 8.1.x is actively maintained, so more maintenance releases will be made available, according to our monthly release cycle.

Change log

Drupal 8.1.7 is a security release only. For more details, see the 8.1.7 release notes. A complete list of all changes in the stable 8.1.x branch can be found in the git commit log.

Security vulnerabilities

Drupal 8.1.7 was released in response to the discovery of security vulnerabilities. Details can be found in the official security advisories:

To fix the security problem, please upgrade to Drupal 8.1.7.

Update notes

See the 8.1.7 release notes for details on important changes in this release.

Known issues

See the 8.1.7 release notes for known issues.

Categories: Drupal

Drupal.org frontpage posts for the Drupal planet: Drupal Core - Highly Critical - Injection - SA-CORE-2016-003

Mon, 2016-07-18 06:53
Description

Drupal 8 uses the third-party PHP library Guzzle for making server-side HTTP requests. An attacker can provide a proxy server that Guzzle will use. The details of this are explained at https://httpoxy.org/.

CVE identifier(s) issued
  • CVE-2016-5385
Versions affected
  • Drupal core 8.x versions prior to 8.1.7
Solution

Install the latest version:

  • If you use Drupal 8.x, upgrade to Drupal core 8.1.7
  • If you use Drupal 7.x, Drupal core is not affected. However you should consider using the mitigation steps at https://httpoxy.org/ since you might have modules or other software on your server affected by this issue. For example, sites using Apache can add the following code to .htaccess:
    <IfModule mod_headers.c> RequestHeader unset Proxy </IfModule>

We also suggest mitigating it as described here: https://httpoxy.org/

Also see the Drupal core project page.

What if I am running Drupal core 8.0.x?

Drupal core 8.0.x is no longer supported. Update to 8.1.7 to get the latest security and bug fixes.

Why is this being released Monday rather than Wednesday?

The Drupal Security Team usually releases Security Advisories on Wednesdays. However, this vulnerability affects more than Drupal, and the authors of Guzzle and reporters of the issue coordinated to make it public Monday. Therefore, we are issuing a core release to update to the secure version of Guzzle today.

Contact and More Information

The Drupal security team can be reached at security at drupal.org or via the contact form at https://www.drupal.org/contact.

Learn more about the Drupal Security team and their policies, writing secure code for Drupal, and securing your site.

Follow the Drupal Security Team on Twitter at https://twitter.com/drupalsecurity

Front page news: Planet DrupalDrupal version: Drupal 8.x
Categories: Drupal

Drupal core announcements: Drupal 8.x core release on Monday, July 18 (update to previously scheduled window)

Sun, 2016-07-17 10:28

The Drupal core security release window has been moved to Monday, July 18. See the PSA announcement for the release for details.

Categories: Drupal

Powered By