Lullabot: Not your grandparent’s Drupal, with Angie “Webchick” Byron

Planet Drupal - 15. Juni 2018 - 0:39
Mike and Matt talk with Angie "Webchick" Byron on what she's been up to, various Drupal initiatives, and what Drupal needs to do to succeed.

Programm der heise DevSec ist online

heise online Newsticker - 14. Juni 2018 - 18:30
Die Konferenz zur sicheren Softwareentwicklung geht nach der ausverkauften Premiere im Oktober in die zweite Runde.

DSGVO: Kein schneller Schutz vor Abmahnungen

heise online Newsticker - 14. Juni 2018 - 18:00
Die CDU/CSU-Bundestagsfraktion konnte sich nicht damit durchsetzen, eine "Soforthilfe" für das Abmahnproblem wegen der EU-Datenschutzverordnung zu schaffen.

Salesforce: Aufbruchstimmung bei Digitalisierung ist angekommen

heise online Newsticker - 14. Juni 2018 - 18:00
Auf der Cebit in Hannover präsentiert der Cloud-Diensteanbieter gemeinsam mit über hundert Partnern und Kunden die mögliche Einsatzgebiete seiner Produkte.

Intel-Grafikprozessor soll 2020 kommen

heise online Newsticker - 14. Juni 2018 - 18:00
Intel bestätigt Pläne für eigene GPU-Chips, die es ab 2020 geben soll – und begibt sich damit in Konkurrenz zu AMD und Nvidia.

Apple erschwert Adressbuchweitergabe für iOS-Apps

heise online Newsticker - 14. Juni 2018 - 17:30
Mit neuen Regeln soll unterbunden werden, dass Entwickler die iPhone-Kontaktliste verkaufen. Auch die Überwachung der Nutzung anderer Apps ist nun tabu.

ZTE: US-Senatoren wollen Rücknahme der Handels-Sanktionen stoppen

heise online Newsticker - 14. Juni 2018 - 17:00
US-Senatoren machen mobil gegen Trumps Entscheidung, das ZTE-Embargo gegen eine Milliardenstrafe aufzuheben und wollen eine gegenteilige Entscheidung erzwingen.

Nach Kritik von Amazon: Seattle schafft Obdachlosen-Steuer wieder ab

heise online Newsticker - 14. Juni 2018 - 17:00
Einen Monat nachdem Seattle eine Steuer eingeführt hat, mit der Amazon & Co. an Maßnahmen gegen Obdachlosigkeit beteiligt werden sollten, folgt der Rückzieher.

Mars-Rover Opportunity: Riesiger Sandsturm wächst, Kontakt abgebrochen

heise online Newsticker - 14. Juni 2018 - 17:00
Die NASA hat keinen Kontakt mehr zu ihrem Rover Opportunity. Der hat wohl fast alle Funktionen abgeschaltet und wartet auf das Ende eines riesigen Sandsturms.

Acro Media: Web to Print with Drupal Commerce

Planet Drupal - 14. Juni 2018 - 16:45
Empower your customers to customize products.


There is a high likelihood that the tshirt on your back or in your closet started life as someone’s idea that was being uploaded to an online tool. The idea that a person could not only buy tshirts, but design them in a tool and approve the proof before payment seems almost commonplace. Why aren’t more people talking about this? Your customers are expecting more tailored experiences when buying decorated apparel, signage and personalized promotional products from the small to medium web store fronts. Getting the “Web to Print” toolset just right on Drupal is not easy.

Here’s just a few of the expectations for ordering printed materials from the web on Drupal:

  • Drupal integration: Full integration with existing Drupal website
  • Intuitive editor experience: Drag and drop toolset, uploading of files (jpg, png, tiff, pdf, eps, ai, psd), cropping and quick fixes to pictures, lots of fonts, pop-over text formatting, white labelled branding with plenty of customizations, low resolution upload warnings, and mobile friendly web to print tool.
  • Proof and checkout workflow: Print-quality PDF proof, edit before purchase, edit after purchase, CMYK color space, super large files that need processing
Getting off the bespoke product editor island

An example of a bespoke web to print tool Acro Media built with Drupal and jQuery UI.

Like many Drupal agencies, there’s rarely a problem we face that can’t be solved with in-house open source tools. Before we decry the problems, we are very proud of what we accomplished in the past given budget and available tools. With jQuery UI and html-to-pdf experience, we’ve built these kinds of tools before, to varying degrees of success. Every time we tackled a project like web-to-print, the struggle became very real. With minimal hours, the tools we knew and loved created a functional experience that was hard to maintain and very error prone.

More often than not, we had trouble with converting HTML to PDF reliably enough for high-resolution print-quality, especially with customer supplied imagery and layout. Offering fonts in a customized product builder is challenging to get right, especially when you’re creating a PDF that has to have the font attached. The RGB colorspace doesn’t translate easily to CMYK, the most common four color process for printing. And all of our experience in software revolved around pixels, not these things called picas. In this crazy world resolution could go as high as 3200 dpi on standard printers, dimensions suddenly couldn’t be determined based on pixels.

When one of our clients that had a tool we had built with existing technologies asked for some (not all) of the features mentioned in the beginning of the article, we also wanted to solve all the technical challenges that we grappled with over a year ago. As the planning stage was coming to an end, it was clear the budget wasn’t going to support such a complicated software build.

Product Customization is not the right phrase

Example screenshot of keditor in action.

We started to look for product customization tools and found nada. Then we looked for web layout tools which would maybe give Drupal a better HTML editing experience, but found a disappointing lack of online web to print solutions. We did find grapejs, innovastudio, and keditor

But, almost universally, these javascript-based libraries were focused on content and not editing products that would be printed. We needed something that had the goal of creating a printable image or PDF with a tight integration around the editor experience. We had nearly convinced ourselves there wasn’t a vertical for this concept, it seemed like nearly all product builders in the wild were powered by one-off conglomerations of toolsets.

Web to Print using Customer’s Canvas works with Drupal, right?

Finally, via a project manager, an industry phrase was discovered that opened the floodgates: web to print. After a bit of sifting through the sales pitch of all the technologies, almost all tools were found to be cumbersome and hard to integrate in an existing Drupal website, save one. Customer’s Canvas checked all the boxes and then some:

  • SAAS (so we don’t have to host customer’s images, or maintain the technology)
  • White label
  • More than fully featured
  • Completely customizable
  • Iframe-friendly. Meaning we could seamlessly plop the product customization tool into an existing or new layout.

Example of Customers Canvas running in Drupal Commerce.

To make an even longer story short, we jumped on board with Customer’s Canvas and built the first (to our knowledge) third party web to print Drupal 7 module. We might make a Tech Talk regarding the installation and feature set of the module. Until then, here’s what you can do:

  1. Download and install the module
  2. Provide some API credentials in the form of a javascript link
  3. Turn on the Drupal Commerce integration
  4. Provide some JSON configuration for a product via a field that gets added to your choice of product types.
  5. Click on Add to Cart for a Customer’s Canvas product
  6. Get redirected to a beautiful tool
  7. Click “Finish” and directed to a cart that can redirect you back to edit or download your product.
  8. As a store administrator, you can also edit the product from the order view page.

Drupal 8 and Web to Print and the Future

Currently, the module is built for Drupal 7. Upgrading to Drupal 8 Commerce 2 is definitely on our roadmap and should be a straightforward upgrade. Other things on the roadmap:

  • Better B2B features
    You can imagine a company needs signs for all of it’s franchisee partners and would want the ability to create stores of customizable signage. With Commerce on Drupal 8, that would be pretty straightforward to build.
  • More download options
    Customer’s Canvas supports lower res watermarked downloads for the customers as well as the high res PDF downloads. Currently the module displays the high resolution for all parties.
  • Better administrative interface
    If you’re using Drupal 7, the integration for this module is pretty easy, but the technical experience required for creating the JSON formatting for each product is pretty cumbersome. So it would be awesome (and very possible) to build out the most common customizations in an administration interface so you wouldn’t have to manage the JSON formatting for most situations.
  • Improve the architecture
    Possibly support Customer’s Canvas templates like entities that are referenced so that you could create a dozen or so customizable experiences and then link them up to thousands of products.
  • Webform support
    The base module assumes your experience at least starts with an entity that has fields and gets rendered. We could build a webform integration that would allow the webform to have a customer’s canvas build step. T-shirt design content anyone?
Integration can be a game changer

One of the big reasons we work with Drupal and Drupal Commerce is that anything with an API can be integrated. This opens the doors to allow the platform to do so much more than any other platform out there. If an integration needs to be made, we can do. If you need an integration made, talk to us! We're happy to help.

Patchday: Microsoft verarztet 50 Sicherheitslücken

heise online Newsticker - 14. Juni 2018 - 16:30
In vielen Windows-Versionen klafft unter anderem eine kritische Lücke in der DNS-Programmierschnittstelle. Sicherheitsupdates stehen bereit.

Fortnite jetzt für die Nintendo Switch erhältlich

heise online Newsticker - 14. Juni 2018 - 16:30
Fortnite: Battle Royale kann jetzt auch auf der Nintendo Switch kostenlos gespielt werden. Das hat Nintendo in einem sonst ereignislosen E3-Stream angekündigt.

Australien will mit Unterwasser-Internetkabel Chinas Einfluss bremsen

heise online Newsticker - 14. Juni 2018 - 15:30
Eigentlich sollte der chinesische Konzern Huawei die Verlegung eines neuen Unterseekabels zu den Salomonen verantworten. Das passte Australien aber nicht.

"Beweg dich oder stirb" – Digitaler Darwinismus auf der Cebit

heise online Newsticker - 14. Juni 2018 - 15:30
Die Digitalisierung ist für Firmen ein Mammutprojekt. Aber wer sie verpasst, wird untergehen, sind sich Speaker auf der Cebit einig. Die Haie werden sie holen.

c't Spaß mit Technik: Projekte für Maker, Nachwuchsprogrammierer und Kreative

heise online Newsticker - 14. Juni 2018 - 15:00
Vom Katamaran mit PC-Lüfter-Antrieb bis zum Lego-Roboter-Hack: Das neue c't-Sonderheft Spaß mit Technik bündelt 25 Mitmach-Projekte rund um PC, Smartphone & Co.

Evolving Web: Resizing Fields in Drupal 8 Without Losing Data

Planet Drupal - 14. Juni 2018 - 15:00

Drupal's field system is awesome and it is one of the reasons why I started using Drupal in the first place. However, there are some small limitations in it which surface from time to time. Say, you have a Text (Plain) field named field_one_liner which is 64 characters long. You created around 30 nodes and then you realized that the field size should have been 255. Now, if you try to do this from Drupal's field management UI, you will get a message saying:

There is data for this field in the database. The field settings can no longer be changed.

So, the only way you can resize it is after deleting the existing field! This doesn't make much sense because it's indeed possible to increase a field's size using SQL without saying goodbye to the data.

In this tutorial, we'll see how to increase the size of an existing Text (Plain) field in Drupal 8 without losing data using a hook_update_N().

Assumptions
  • You have intermediate / advanced knowledge of Drupal.
  • You know how to develop modules for Drupal.
  • You have basic knowledge of SQL.
Prerequisites

If you're going to try out the code provided in this example, make sure you have the following field on any node type:

  • Name: One-liner
  • Machine name: field_one_liner
  • Type: Text (Plain)
  • Length: 64

After you configure the field, create some nodes with some data on the One-liner field.

Note: Reducing the length of a field might result in data loss / truncation.

Implementing hook_update_N()

Reference: Custom Field Resize module on GitHub

hook_update_N() lets you run commands to update the database schema. You can create, update and delete database tables and columns using this hook after your module has been installed. To implement this hook, you need to have a custom module. For this example, I've implemented this hook in a custom module which I've named custom_field_resize. I usually name all my custom modules custom_ to namespace them. In the custom module, we implement the hook in a MODULE.install file, where MODULE is the machine-name of your module.

/** * Increase the length of "field_one_liner" to 255 characters. */ function custom_field_resize_update_8001() {}

To change the field size, there are four things we will do inside this hook.

Resize the Columns

We'll run a set of queries to update the relevant database columns.

$database = \Drupal::database(); $database->query("ALTER TABLE node__field_one_liner MODIFY field_one_liner_value VARCHAR(255)"); $database->query("ALTER TABLE node_revision__field_one_liner MODIFY field_one_liner_value VARCHAR(255)");

If revisions are disabled then the node_revision__field_one_liner table won't exist. So, you can remove the second query if your entity doesn't allow revisions.

Update Storage Schema

Resizing the columns with a query is not sufficient. Drupal maintains a record of what database schema is currently installed. If we don't do this then Drupal will think that the database schema needs to be updated because the column lengths in the database will not match the configuration storage.

$storage_key = 'node.field_schema_data.field_one_liner'; $storage_schema = \Drupal::keyValue('entity.storage_schema.sql'); $field_schema = $storage_schema->get($storage_key); $field_schema['node__field_one_liner']['fields']['field_one_liner_value']['length'] = 255; $field_schema['node_revision__field_one_liner']['fields']['field_one_liner_value']['length'] = 255; $storage_schema->set($storage_key, $field_schema);

The above code will update the key_value table to store the updated length of the field_one_liner in its configuration.

Update Field Configuration

We took care of the database schema data. However, there are other places where Drupal stores the configuration. Now, we will need to tell the Drupal config management system that the field length is 255.

// Update field configuration. $config = \Drupal::configFactory() ->getEditable('field.storage.node.field_one_liner'); $config->set('settings.max_length', 255); $config->save(TRUE);

Finally, Drupal also stores info about the actively installed configuration and schema. To refresh this, we will need to re-save the field storage configuration to make Drupal detect all our changes.

// Update field storage configuration. FieldStorageConfig::loadByName($entity_type, $field_name)->save();

After this, running drush updb or running update.php from the admin interface should detect your hook_update_N() and it should update your field size. If you're committing your configuration to git, you'll need to run drush config-export after running the database updates to update the config in the filesystem and then commit it.

Conclusion

Though we've talked about resizing a Text (Plain) or varchar field in this tutorial, we can resize any field type which can be safely resized using SQL. In certain rare scenarios, it might be necessary to create a temporary table with the new data-structure, copy the existing data into that table with queries and once all the data has been copied successfully, replace the existing table with the temporary table. For example, if you want to convert a Text (Plain) field to a Text (Long) field or some other type.

Maybe someday we'll have a resizing feature in Drupal where Drupal will intelligently allow us to increase a field's size from it's field UI and only deny reduction of field size where there is a possibility of data loss. But, in the meanwhile, we can use this handy trick to resize our fields. Thanks for reading! Please leave your comments / questions in the comments below and I'll get back to them as soon as I have time.

+ more awesome articles by Evolving Web

#heiseshowXXL live von der Cebit: Autonome und E-Autos, Mobilität der Zukunft

heise online Newsticker - 14. Juni 2018 - 14:30
Die #heiseshowXXL täglich ab 15:30 live auf der d!talk-Bühne in Halle 13 und im Livestream: Am heutigen Dienstag dreht sich alles um die Mobilität der Zukunft.

Tesla kündigt 9 Prozent der Mitarbeiter – Druck auf Elon Musk steigt

heise online Newsticker - 14. Juni 2018 - 14:30
Bei Tesla müssen sich möglicherweise mehr als 3000 Mitarbeiter auf eine Kündigung einstellen, damit das Unternehmen endlich profitabel werden kann.

Mit Gen-Therapie gegen das Altern

heise online Newsticker - 14. Juni 2018 - 14:30
Ist es möglich, die Alterung zu stoppen oder sogar umzukehren? Ein Start-up von Harvard-Biologen will erst Tiere und bald auch Menschen behandeln.

AT&T darf Time Warner übernehmen

heise online Newsticker - 14. Juni 2018 - 14:30
Ein US-Gericht erlaubt dem Telecom-Konzern AT&T, Time Warner zu übernehmen – sehr zur Freude anderer fusionswilliger US-Konzerne wie T-Mobile und Sprint.