Drupal

Responsive Image Formatter Link to Image Style

New Drupal Modules - 25 April 2017 - 8:55am

This module provides an additional formatter for image core field to link to an image style.

Installation

Install as you would normally install a contributed Drupal module.
See: drupal.org/documentation/install/modules-themes/modules-8 for further information.

Categories: Drupal

Aten Design Group: Using BrowserSync with Drupal 8

Planet Drupal - 25 April 2017 - 8:15am

TLDR: Just here for Browsersync setup? Skip to the steps.

I’m always looking for ways to reduce the time between saving a file and seeing changes on the screen.

When I first started working with Drupal, back in the day, I would ftp changes to a server and refresh the page. Once I found Transmit, I could mount a remote directory locally and automatically save files to the server. At the time, my mind was blown by the efficiency of it. In hindsight, it seems so archaic.

Then I started working with development teams. Servers were typically managed with version control. If I wanted to make changes to the server, I had to commit code and push it up. It was time to act like a grown up and develop with a local server.

The benefits of developing locally are too numerous to list here, but the most obvious is not having to push changes to a remote server to see the effects. I could just save a file, switch to the browser and refresh! What was taking minutes was reduced to seconds.

My progression of development practices went something like this.

“Oy, hitting cmd+r is so tedious. What’s this? LiveReload? OH MY GOD! It refreshes the page immediately upon saving! It even injects my CSS without refreshing the page! I’m so super fast right now! Whoa! Less! I can nest all my CSS so it matches the DOM exactly! Well that was a terrible idea. Not Less’s fault but ‘Hello Sass!’. Because Compass! And Vertical Rhythm! And Breakpoint! And Susy! Holy crap, it’s taking 8-12 seconds to compile CSS? Node sass you say?. That’s so much faster! Back down to 3 seconds. Wait a minute, everything I’m using Compass for, PostCSS handles. BOOM! Milliseconds!”

This boom and bust cycle of response times of mine has been going on for years and will continue indefinitely. Being able to promptly see the effects of your changes is incredibly important.

In 1968, Robert Miller published a paper in which he defined 3 thresholds of human-computer response times.

  • .1 sec. To feel like you are directly manipulating the machine
  • .1 - 1 sec. To feel like you are uninhibited by the machine, but long enough to notice a delay
  • > 10 sec. At this point, the user has lost focus and is likely to move onto another task while waiting for the computer.

In short, less than a second between making a file change and seeing the result is ideal. More than that and you’re likely to lose focus and check your email, Slack or Twitter. If it takes longer than 10 sec. to compile your code and refresh your browser, your productivity is screwed.

One of my favorite tools for getting super fast response times is Browsersync. Browsersync is a Node.js application that watches your files for changes then refreshes your browser window or injects new CSS into the page. It’s similar to LiveReload but much more powerful. The big difference is that Browsersync can be run in multiple browsers and on multiple devices on the same LAN at the same time. Each connected browser will automatically refresh when code changes. It also syncs events across browsers. So if you scroll the page in one browser, all your connected browsers scroll. If you click in one browser, all browsers will load the new page. It’s incredibly useful when testing sites across devices.

For simple sites, Browsersync will boot up its own local http server. For more complex applications requiring their own servers, such as Drupal, Browsersync will work as a proxy server. Setup is pretty simple but I’ve run into a few gotchas when using Browsersync with Drupal.

Setting up Browsersync Local dev environment

First things first, you’ll need a local dev environment. That’s beyond the scope of this post. There are a few great options out there including DrupalVM, Kalabox and Acquia Dev Desktop.

For this tutorial, we’ll assume your local site is being served at http://local.dev

Install Node

Again, out of scope. If you don’t already have node installed, download it and follow the instructions.

Install Browsersync

Browsersync needs to be installed globally.

npm install browser-sync -g

Change directories to your local site files.

cd wherever/you/keep/your/drupal/docroot

Now you can start Browsersync like so:

browser-sync start --proxy "local.dev" --files "**/*.twig, **/*.css, **/*.js”

The above will start a browsersync server available at the default http://localhost:7000. It will watch for changes to any Twig templates, CSS or JS files. When a change is encountered, it will refresh any browsers with localhost:7000 open. In the case of CSS, it will inject just the changed CSS file into the page and rerender the page rather than reloading it.

Making Drupal and Browsersync play nicely together

There’s a few tweaks we’ll need to do to our Drupal site to take full advantage of our Browsersync setup.

Disable Caching

First we want to make sure page caching is disabled so when we refresh the page, it’s not serving the old cached version.

Follow the steps outlined under “Enable local development settings” in the Disable Drupal 8 caching documentation.

Now when you change a Twig template file, the changes will be reflected on the page without having to rebuild the cache. Keep in mind, if you add a new file, you’ll still need to rebuild the cache.

Avoid loading CSS with @import statements

This gotcha was much less obvious to me. Browsersync will only recognize and refresh CSS files that are loaded with a link tag like so:

<link rel="stylesheet" href="/sites/.../style.css" media="all">

It does not know what to do with files loaded via @import tags like this:

<style> @import url('/sites/.../style.css'); </style>

This is all well and good as Drupal uses link tags to import stylesheets unless you have a whole lot of stylesheets, more than 31 to be exact. You see, IE 6 & 7 had a hard limit of 31 individual stylesheets. It would ignore any CSS files beyond that. It’s fairly easy to exceed that maximum when CSS aggregation is turned off as any module or base theme installed on your site can potentially add stylesheets. Drupal has a nice workaround for this by switching to the aforementioned @import statements if it detects more than 31 stylesheets.

We have two ways around this.

1. Turn preprocessing off on specific files

The first involves turning CSS aggregation (a.k.a. CSS preprocessing) on for your local site and manually disabling it for the files you are actually working with.

In settings.local.php, set the following to TRUE:

$config['system.performance']['css']['preprocess'] = TRUE;

Then in your [theme_name].libraries.yml file, turn preprocessing off for any files you are currently working on, like in the following example.

global: version: 1.0.x css: theme: build/libraries/global/global.css: { preprocess: false }

This will exclude this file from the aggregated CSS files. This approach ultimately leads to a faster site as your browser loads considerably fewer CSS files. However, it does require more diligence on your part to manage which files are preprocessed. Keep in mind, if you commit the above libraries.yml file as is, the global.css file will not be aggregated on your production environment as well.

2. Use the Link CSS module

The easier alternative is to use the Link CSS module. When enabled, this module will override Drupal’s @import workaround and load all files via the link tag regardless of how many. The only downside to this approach is the potential performance hit of still loading all the unaggregated CSS files which may not be a big deal for your environment.

Add a reload delay if needed

In some cases, you may want to add a delay between when Browsersync detects a change and when it attempts to reload the page. This is as simple as passing a flag to your browsersync command like so.

browser-sync start --proxy "d8.kbox.site" --files "**/*.twig, **/*.css, **/*.js" --reload-delay 1000

The above will wait 1 second after it detects a file change before reloading the page. The only time I’ve ever needed this is when using Kalabox as a local development environment. Your mileage may vary.

In addition to the reload delay flag, Browsersync has a number of other command line options you may find useful. It’s also worth noting that, if the command line approach doesn’t suit you, Browsersync has an api that you can tie into your Gulp or Grunt tasks. Here at Aten we use Browsersync tied into gulp tasks so a server can be started up by passing a serve flag to our build task. Similar to the following gulp compile --watch --serve

Categories: Drupal

Address USPS Validation Widget

New Drupal Modules - 25 April 2017 - 8:13am

Provides field widget for Address field validation using USPS Web Tools API.

Categories: Drupal

User Logout Confirm

New Drupal Modules - 25 April 2017 - 6:47am

INTRODUCTION
------------

This module enables user logout confirmation feature

INSTALLATION
------------

* Install as you would normally install a contributed Drupal module. See:
https://drupal.org/documentation/install/modules-themes/modules-7
for further information.

CONFIGURATION
-------------

Categories: Drupal

Swish payment

New Drupal Modules - 25 April 2017 - 6:45am

This is an implementation of the Swish payment API. Configuration and utility classes to make Swish payments and a Block submodule to make simple payment forms on pages.

Categories: Drupal

InternetDevels: The peculiarities of content modeling in Drupal 8

Planet Drupal - 25 April 2017 - 6:22am

We continue to describe the functional capabilities of “the big eight” as Drupal 8 has many improvements over its previous versions. Take a look at the innovations in Drupal 8.3.0, which is its latest minor release that came out this month.

Read more
Categories: Drupal

Nuvole: Configuration Management dimensions

Planet Drupal - 25 April 2017 - 5:07am
Key points from our configuration management sessions.

Unfortunately none of us from Nuvole are attending DrupalCon Baltimore and can’t, therefore, attend the “hallway track” and join discussions in person. We have held presentations about advanced configuration management in Drupal 8 at all Drupal events we attended in the last year including the last DrupalCon in Dublin. So I’ll try to cover some concepts here that could help the discussion about how the configuration management can be improved.

To me there are at least two important dimensions to configuration management in Drupal 8 and different contrib project have sprouted to address:

Vertical: transfer configuration between different environments of the same site.
Horizontal: transfer configuration between different sites.

Following are a few contrib solutions and core issues that address the different itches. This is not meant to be an exhaustive or definitive list but highlight the different problem spaces. Many more contrib solutions address some issues in this space to accommodate various different workflows.

Vertical

Drupal 8 core only addresses this use case, however, there are some important cases not covered (yet). The management of configuration between the different environments is best taken care of by importing and exporting the whole sites configuration together.

Installing from existing configuration:

Contrib solution: Config installer
Core issues: Allow a site to be installed from existing configuration, Allow a profile to be installed from existing config

Environment specific configuration (ie devel only on develop)

Contrib solution: Config Split
Core issues: Allow exported configuration to be environment-specific, Allow development modules to opt out of config-export

Configuration with Content

Contrib solution: Default Content, Deploy

Horizontal

Due to the fact that the same tools can be used for both dimensions and the fact that in Drupal 7 features was abused for doing the vertical configuration management as well this concept may not be so clear. Ideally configuration between sites is shared from the development environment of one site to the development environment of another, and the vertical tools with drupal core are used for deployment. Moving configuration between different sites is done by moving a subset of configuration between environments.

Re-using a set of configuration in another site

Contrib Solution: Features
There are many more modules designed to deal with distributions and dealing with the paradigm that sites now own the configuration.

Inheriting installation profiles

Core issue: Allow profiles to provide a base/parent profile

Multisite with large portion of shared configuration

Contrib Solution: Config Split
While this is not the original problem it tries to solve, it is reported to be used for it..

Conclusion

I may have an obvious bias towards config split since we maintain that module but it is just one of many config related modules. I hope there is a fruitful discussion in Baltimore about configuration management in Drupal 8. BoF

Related blog posts: Tags: Drupal 8Drupal PlanetDrupalConCode Driven Development
Categories: Drupal

Ckeditor Shortcodes

New Drupal Modules - 25 April 2017 - 4:14am

This is a sample project Drupal to include plugin Shortcode in Ckeditor, this plugin helps you to add facility shortcut text using popup with required field.

To complete Shortcode with Drupal you need to install module Advanced shortcodes

First you need install plugin Ckeditor Ckeditor Shortcode , i have create it if you have any issue please contact me here or by Github :).

Categories: Drupal

Google Drive Field

New Drupal Modules - 25 April 2017 - 4:07am

This module is used to upload files to google drive directly. It provides a field type Gdrive in the field UI.

This module bypasses the local storage and upload the file directly to a configured google drive account and displays the file link on node detail page.

Dependencies:

Categories: Drupal

Code Positive: AMP for Drupal 8

Planet Drupal - 25 April 2017 - 4:00am

Interested in lighting fast performance for your mobile site? Page's that load pretty much instantly? Here's how the AMP project has pushed boundaries to achieve exactly that.

 

 

Categories: Drupal

Code Positive: Configuring AMP for Drupal 8

Planet Drupal - 25 April 2017 - 4:00am

Tips and tricks to get AMP working for your Drupal 8 site.

 

 

Categories: Drupal

Manifesto: How I learned to stop worrying and love Drupal contribution

Planet Drupal - 25 April 2017 - 3:34am
Over the last five years I've worked in a variety of senior Drupal developer positions, but my dirty secret is, I've never really contributed back to Drupal. Until the last few weeks, that is. So, I thought I'd take the time to write about why that is, and what's changed.
Categories: Drupal

Agiledrop.com Blog: AGILEDROP: Drupal Logos with Hats

Planet Drupal - 25 April 2017 - 1:43am
It's back! You did not really think that our Druplicon marathon was finished, did you? Well, it's not. We still have some areas to explore. After Humans and Superhumans, Fruits and Vegetables, Animals, Outdoor activities, National Identities, Emotions and Human Professions, we have seen that not all Druplicons with hats were covered. So, here are Drupal Logos with hats.   Druplicon with Santa hat     Druplicon with snow hats       Druplicon with ascot hat (Drupal day Bilbao 2014)     Druplicon with fedora (Drupal Camp Buenos Aires 2009)     Druplicon with swimming hat (DrupalCamp… READ MORE
Categories: Drupal

blog.studio.gd: Drupal 8 Views Plugins (Part 2) : The display extender plugin

Planet Drupal - 25 April 2017 - 1:04am
Let's see how and why to use a views display extender plugin.
Categories: Drupal

blog.studio.gd: Views Plugins (Part 1) : Simple area handler plugin

Planet Drupal - 25 April 2017 - 1:04am
In this series I will show you how to make use of the new Drupal 8 Plugin system, we begin with a simple example : the views area handler plugins.
Categories: Drupal

blog.studio.gd: Overview of CMI in Drupal 8

Planet Drupal - 25 April 2017 - 1:04am
Some notes about the new Configuration management system in Drupal 8
Categories: Drupal

blog.studio.gd: Migrate to Drupal 8 from a custom site

Planet Drupal - 25 April 2017 - 1:04am
Migrate is now included in the Drupal core for making the upgrade path from 6.x and 7.x versions to Drupal 8.

In this article will see how to use the Drupal migration framework to migrate custom sites to drupal 8.
Categories: Drupal

blog.studio.gd: Inline Entity Display

Planet Drupal - 25 April 2017 - 1:04am
Handle referenced entity fields directly in the parent entity
Categories: Drupal

Aegir Composer

New Drupal Modules - 24 April 2017 - 10:31pm

This module extends Aegir's platform deployment strategies by adding support for Composer.

Categories: Drupal

OSTraining: Drupal 8 Field Layout Alternative to the Display Suite

Planet Drupal - 24 April 2017 - 6:01pm

In Drupal 7 to create custom displays, you would probably use Display Suite.

Drupal 8 just added a potential alternative to the Display Suite in the core experimental modules. The Field Layout and Layout Discovery modules will allow you to assign a layout to specific content types.

Categories: Drupal

Pages

Subscribe to As If Productions aggregator - Drupal