Red Route: A day of yak shaving and narrowly avoiding being nerd sniped

Planet Drupal - 4 March 2016 - 12:22pm

As I previously mentioned, I'd got a basic migration of configuration and content from the Drupal 6 Gallery Guide to a new Drupal 8 site up and running fairly quickly. It's clear that a lot of good work has been done on the various migrate modules. It can't have been easy, so thanks and kudos to the people involved.

The next task was to get the more complex data migrated. One of the main features on the site is keeping the addresses of art galleries, and showing their locations on maps. The D6 site used the Location, Gmap, and Views modules for this, but 2 out of 3 of those don't have a stable D8 version yet, and don't look like having one any time soon.

Try out the Address module, I thought. But that has dependencies on the address library, and the recommended way to install that is with Composer. For some reason I couldn't get Composer working properly on my VDD Vagrant box, and I was starting to get frustrated.

I'd been meaning to try out Drupal VM for a while, and this seemed like an opportune moment. Trouble was, it fell over on the installation steps, with some problem to do with ansible-galaxy. To me that sounds like something out of one of Edward Lear's nonsense poems. So often I hear my more devops-inclined colleagues talk about tools, and I have no idea what they're talking about. They'd probably say the same thing about some of the dependencies in the grunt or gulp setups I work with.

Anyway, after some Googling and looking at Github issues, and editing a file written in a language I've never used before, and once assorted other yaks had been shaved, I had a shiny new VM set up, with Composer and a new version of Drush, and a bunch of other things I may need to care about later. I even had a clean Drupal install as part of the vagrant provision.

Having installed Address and Geolocation, they both seem to work well. The only trouble is that they don't talk to each other. Geolocation gets and stores the latitude and longitude, and Address stores the street and the town and all that jazz. But they don't talk to each other. If you're using both modules, anyone creating content would need to enter the location in two different fields.

I was about to dive down the potential rabbit hole of trying to patch Geolocation to populate the fields provided by Address. Integration between Address and Geolocation would improve the user experience when people are creating new galleries, but the site already has data for over 500 galleries, so I can worry about that later. It's a good example of how easy it is to get sidetracked by interesting-looking problems. For now, it should be possible to write a custom migration to get the data from the D6 site. And I just need to remind myself to stay focused on the minimum viable product...

Tags: DrupalDrupal 8The Gallery Guidedevelopmentdevopstools
Categories: Drupal

Acquia Developer Center Blog: Drupal How-To: Responsive or Adaptive Images?

Planet Drupal - 4 March 2016 - 12:01pm

In this 3-part Drupal How-To series, I'm going to show you how various options for configuring images on your site. In Part 1, we looked at how to tweak the default image options. In Part 2, we saw ways to allow inline images. In this post, I’ll discuss the various options for responsive/adaptive images on your site.

Tags: acquia drupal planet
Categories: Drupal

Greg Boggs: Drupal 8 Breadcrumbs - Add the Current Page

Planet Drupal - 4 March 2016 - 11:36am

Breadcrumbs are a pain point in Drupal 7. If you don’t know how breadcrumbs are supposed to work, go read this. The crumb should start with home and continue through to an unlinked crumb of the current page. Crumbs were implemented poorly, and breadcrumbs were difficult to modify in a module. Further, they were based on items in the menu. The breadcrumbs didn’t even allow you to edit the home title or include the current page title as an unlinked crumb. So, if you wanted breadcrumbs on a Drupal site, the first step was to choose 1 of 10 different modules to build them for you. Making matters worse, some themes decided to program breadcrumbs for you as well. If you’re stuck with a Drupal 7 breadcrumb problem, use a module I help maintain, Easy Breadcrumb. Trust me. I’ve got this for you.

Breadcrumb Improvements

Drupal 8 vastly improves breadcrumbs, but core still gets them wrong. They are based on the current page path exactly like Easy Breadcrumb in Drupal 7 which is a huge improvement. So, what did they get wrong? The current page title is missing. Bummer. So close. But, not hard to fix. So, lets do it! If someone tells you to program the breadcrumbs into your theme, don’t listen to them. They are doing it wrong. Themes should work with markup and presentation. They shouldn’t implement complex, reusable logic.

Drupal 8 has refactored breadcrumbs making them much easier for developers to extend or replace. This new architecture makes it easy for us to correct Drupal 8’s breadcrumbs. Unfortunately, the code from Larry’s post is a bit out of date and doesn’t work anymore. So, lets look at the code pulled from my module Current Page Crumb module that adds the current page title to the breadcrumb.

This code extends the PathBasedBreadcrumbBuilder core class to add the current page title to the breadcrumb. Since everything else needed for the breadcrumb is handled by the parent, line 31 does almost all the work for us. From there, we just need a few lines to add the current page’s title. If you’re looking for more examples to completely replace the core breadcrumbs with a custom builder, check out the Drupal 8 version of Easy Breadcrumb which does just that.

Categories: Drupal


Subscribe to As If Productions aggregator - Drupal