Drupal 8 logo Pepper's ghost illusion

Turning your smartphone into a hologram projector has become fairly popular nowadays, although it's technically called Pepper's ghost to create the illusion. Anyway, I had to try it myself too, right ? Building the pyramid isn't that hard and the first try-out is pretty cool to be honest.

So with that going fine, I opened up Blender to create my own animation just for fun. I took the Drupal 8 logo, ripped it apart and let it build itself up again. I quickly wrote an Android application that would just play 4 videos on a surface; and each video in a different rotation. The app is attached at the end if you want to try it out yourself (works well on Motorala, with Lollipop). If all goes well, I'll make it possible to select your own video and make the code public on GitHub. But for now, just enjoy the video. Or start building your own pyramid, it's really fun.

Mobile support for chosen

Chosen is a jQuery plugin which makes select boxes more user-friendly. Currently, support is disabled on mobile devices for various reasons. Enabling the support requires a hack in the source code for now in the AbstractChosen.browser_is_supported function to return true when the userAgent finds Android or iPhone/iPad. You can download the patched version at the bottom (or detail) of the article. The current version is 1.1.0

Chosen will now be enabled on mobile, but touching the element will not work nicely since the plugin doesn't listen for the touchstart event to trigger the functionality. Opening the select box requires touching the element for at least a couple of seconds, which isn't really user-friendly. Luckily, there's an easy way to get around this by writing a couple lines of javascript:

    // Chosen touch support.
    if ($('.chosen-container').length > 0) {
      $('.chosen-container').on('touchstart', function(e){
        e.stopPropagation(); e.preventDefault();
        // Trigger the mousedown event.
        $(this).trigger('mousedown');
      });
    }

That's it, fully functional chosen support on mobile devices!

Topics 

jquery, mobile phone

Crowdsourced translation of Gentse Feesten application

July is approaching fast, which means that Ghent is getting ready for yet another 10 days of celebrating. Just like last year, we'll release our app to make sure you know your way around. Some events are public already of which one is my top favorite so far: Madensuyu is playing on the Boomtown festival on july 22. You will not regret attending that gig!

Last year, the Android version was only available in one language, namely Dutch. This year, we want try todo a little better and get as many languages supported as possible: I'm thinking of English, Spanish, German, Italian, French to begin with. But don't hesitate to translate in any language :) Another plus would be translating everything to Gentsch, the local dialect from Gent. So, I'm looking for people who are willing to translate the strings which should only take maybe 30 minutes of your time. You'll also be credited on the Google Play store, inside the app and in code. One remark: you can leave the locations as is, there's no value in translating those.

I've uploaded all strings using Google's Translator Toolkit which has a friendly interface hiding away the XML. If you have a google account, send me your e-mail through the contact form or just let me know in case I have your contact details already. If you feel comfortable hand editing XML files directly, you can also download the file underneath and send it back to me.

Current status

  • Dutch - needs some update
  • English - needs revision
  • French - done - Thank you Katrien!
  • German - done - Thank you Katrien!
  • Spanish - done - thank you Ruben Teijeiro!
  • Polish - done - thank you Jakub Piasecki!
  • Hungarian - done - thanks you Zsófi Major!
  • German - ongoing

Not a translator, but a die-hard coder ?

The code is still free, so you're welcome to hack along on GitHub.

eps & kaas

2014 marks the beginning of a new company called eps & kaas which I cofounded with 3 other people. We're a digital agency, providing services ranging from mobile applications, websites, consultancy and design.

While you can still contact us (and me, from time to time) for Drupal development, my personal focus is now on Android and iOS development, but also different web technologies like Symfony or Ruby on Rails.

You can find us on the web, Twitter and Facebook. Drop us a note if you think we can help you!

So what about contributions ?

No, I'm not leaving Drupal. However, it's not going to the main technology anymore in my day-to-day work which is why I'm minimising my work on contributed modules: Display Suite is now in the hands of Bram 'aspilicious' Goffings, who has been a major contributor for the module since years. Most other projects have found a new maintainer, others are still waiting, maybe you're interested ?

I'm still around co-maintaining Field API for Drupal 8, or helping out in other areas that interest me, most notable the new configuration management system. We're slowly seeing the end of - yet another - long development cycle, hopefully marked with a release in june. The next big effort to get as many as bright minds together in one place is happening in March for the Drupal Developer Days in Szeged, Hungary. Anyone can help out in different ways: programming, reviewing, playing music, sponsoring plane/hotel tickets and so on.

Music and play

I've been writing songs since september for an album I want to get out this year - no release date yet. This is currently on hold as I need to rehearse songs to play with Last Exit To Loonville on the preselection of Humo's Rock Rally on the 25th of january in Gent. Tickets and more details are on the site of the Vooruit where the event is taking place. So, 8 years after my first appearance on Belgium's biggest rock talent event and more or less the last time I've been on a big stage, I'm back. What a great feeling that will be.

And, as if this year isn't going to be busy enough, I've started writing a play. The goal is to get it performed somewhere in october, so there's still some six months to finish the script. The main characters are alive in my head, the plot is as good as ready; if you're into a bit of absurdness and feel like Mark Everett and the theories of his dad are interesting topics, you'll want to attend this!

I'm sure 2014 is going to be a fantastic year, let it be a great one for you too!

Drupal 8 Field API series part 4: entity (form) displays and display modes

This is part 4 of the Drupal 8 Field API series. We skipped part 3 about field types as the dust hasn't settled yet in terms of API changes. Once we get there, we'll make sure we'll talk about the massive changes that have happened in that area.

In this part, we'll talk about new API's which are, strictly speaking, not part anymore of Field API, they now belong to the Entity Field API. However, the reason the changes exist, directly comes out of a big problem in Drupal 7 in Field API: scattered storage.

Entity display

In Drupal 7, parameters controlling how to render the various "parts" of an entity view in a given view mode were scattered in many separate locations:

  • in $instance['display'] for each individual (Field API) field in the bundle
  • in the 'field_bundle_settings_[entity_type]_[bundle]' variable for the 'extra fields' in the bundle
  • in other places for contrib additions that are not one of the two above (most notably field_group module)

In Drupal 8, all those parameters ("options") for all those parts ("components") are centralised in one single EntityViewDisplay configuration object - which means they can be deployed with CMI - for each entity bundle and view mode. You can access these objects with the entity_get_display() function. All available methods can be found in EntityDisplayInterface.

<?php
entity_get_display
('node', 'article', 'default')
 
// Set 'component_1' to be visible, with weight 1.
 
->setComponent('component_1', array(
   
'weight' => 1,
  ))
 
// Set 'component_2' to be hidden.
 
->removeComponent('component_2')
  ->
save();
?>

Also new in D8 is that all entity and field rendering hooks now receive this EntityDisplay object as a parameter. This means you have direct access to the configuration in your functions, instead of having to figure them out by calling functions to get the definition of field instances, extra fields or other configurations. For the full list of all hooks affected, scroll to the resources part at then end of this article for the change record link.

<?php
function hook_node_view(Node $node, EntityDisplay $display, $view_mode, $langcode) {
  if (
$display->getComponent('mymodule_addition')) {
   
$node->content['mymodule_addition'] = array(
     
'#markup' => mymodule_addition($node),
     
'#theme' => 'mymodule_my_additional_field',
    );
  }
}
?>

Note that currently only Field API fields and extra fields are handled by the EntityViewDisplay object. This is going to change when we introduce component type plugins so everyone will be able to store and access configuration. For more information, follow https://drupal.org/node/1875974.

Entity form display

Just like with the display settings, form settings are scattered all over the place:

  • in $instance['widget'] for each individual (Field API) field in the bundle
  • in the 'field_bundle_settings_[entity_type]_[bundle]' variable for the 'extra fields' in the bundle
  • in other places for contrib additions that are not one of the two above (most notably field_group module)

In Drupal 8, all those parameters ("options") for all those parts ("components") are centralised in one single EntityFormDisplay configuration object for each entity bundle and form mode.This object uses the same EntityDisplayInterface as the EntityViewDisplay object. The consequence of this API is the birth of the counterpart of view modes: form modes.

The direct use case for this was the hacky workaround in Drupal 7 for showing Field API fields on the user registration page. In Drupal 8, you can now configure which fields are available on the user registration page or the edit page. However, more interesting possibilities with this new API will certainly pop up when Drupal 8 is released, most notable inline entity forms.

UI impact

In Drupal 7, the place to manage the fields and control the order in forms is done on the 'manage fields' screen. In Drupal 8, this has has been split out in the 'manage fields' and the 'manage form display' screens. Widget settings are now also managed on this new screen, which allows you to have different widget settings depending on the form mode. The form displays screen also have a 'hidden' region, which allows you to hide certain fields on certain form modes.

Display modes

Drupal 7 has the concept of 'view modes', previously build modes in D6. In D8, we now also have form modes and both of them are configuration entities. Drupal 8 also ships with a UI to manage these display modes. You do not have to rely anymore on contributed modules like 'View modes' or 'Display Suite'.

Resources

Pages

Subscribe to realize.be RSS