/* drucafe */

Tuesday, March 8, 2016

Build unminified CKEditor for Drupal 8

Drupal 8 core contains a minified version of CKEditor in core/assets/vendor/ckeditor/ckeditor.js . It's hard to debug e.g. while writing a custom plugin or widget. So on development server it may be useful to have full unminified version.

There are two methods to produce (make, build) unminified ckeditor.js in place of existing, minified version, both described in core/assets/vendor/ckeditor/build-config.js .

First method is to use CKEditor builder on page http://ckeditor.com/builder and this method didn't work for me (after build there were errors, can't remember exactly what errors but it the unminified ckeditor.js just didn't work on my site.

The other method requires to install Git locally and to clone the dev repository. The result ckeditor.js worked perfectly on my site. The build process is described here and has the following steps:

  • Check the version of your existing CKEditor version which came with the D8 install. It's in file core\assets\vendor\ckeditor\changes.md
  • Open Git console in D8 root directory
  • Make a clone of the ckeditor-dev branch from Git into local ckeditor-dev subdirectory:
    git clone https://github.com/ckeditor/ckeditor-dev.git
  • Change directory into the new one: cd ckeditor-dev
  • Upgrade the local clone to the version checked in the first step (from changes.md file). In my case it was 4.5.5, so: git checkout 4.5.5
  • The build configuration which was originally used by D8 is in file core\assets\vendor\ckeditor\build-config.js. So to prepare to make exactly the same build, copy this file to D8root\ckeditor-dev\dev\builder directory.
  • From ckeditor-dev directory, run the builder shell script with the following flags: ./dev/builder/build.sh --skip-omitted-in-build-config --leave-js-unminified
    It will create release subdirectory with unminified ckeditor version
  • Delete the original core\assets\vendor\ckeditor directory
  • Copy the D8root\ckeditor-dev\dev\builder\release\ckeditor directory into core\assets\vendor.
  • You may also copy D8root\ckeditor-dev\dev\builder\build-config.js file into core\assets\vendor\ckeditor, just in case you delete the builder dev and later need to repeat the whole process again.


Saturday, March 5, 2016

Drupal errors

Drupal 7

After restoring a "backup migrate" backup from production server to test server, I had white screen with "500 Internal Server Error". The test server is on windows so I don't have drush, so I did some things in database manually. No idea whether all steps were necessary or only the last one, but I finally got it working.

First thing I did was clear cache tables. In phpmyadmin, check tables starting with "cache_" and choose operation "Empty" at the bottom of the screen. It didn't help.

Then I changed the system paths (public, private and temp) in database. Table "variable" contains three records: "file_private_path", "file_public_path" and "file_temporary_path". See here how to change them. It didn't help.

Then I noticed (in debugger) that Drupal was complaining about being unable to delete a record from table "semaphore", so I deleted it manually (a record, not the table). It didn't help.

And then finally I noticed that the error message is in debugger is "SQLSTATE[HY000]: General error: 2006 MySQL server has gone away" and it turned out that increasing max_allowed_packet in my.ini helped, as described in this blog.

By the way, next time I have such error I'll start with deleting lines from settings.php which prevent error display on screen (makes sense in production but not on test server) so perhaps the errors will be easier to find out without using debugger.

Friday, February 12, 2016

Adding custom styles to CKEditor in Drupal 8

In my version of Drupal 8 (8.0.3) the CKEditor Styles combo was empty out of the box.


Adding custom styles can be done in two ways. Both ways are more or less explained in this answer, which is not for styles but for rtl language settings, but the procedure is analogous. I'll give a detailed explanation here how to do it both ways.

Thursday, February 11, 2016

Install Drupal 8 console on Windows using composer

Drupal console is a command line tool for Drupal module developers for generating initial module code and for admins to do some administrative tasks. In order to install it on my Windows 7 with XAMPP and with existing composer, following the installation docs, I entered the command:

C:>composer global require drupal/console:@stable
(This installs the stable release instead of latest release)

This gave me the following output.

Tuesday, September 30, 2014

Helpful node API functions for showing node programmatically from scratch

Here is the Drupal 7 node API page with plenty of functions.  I found some of those functions more useful than others, while writing code which displays the nodes programmatically from scratch.

Thursday, February 27, 2014

Jquery Roundabout problem after Jquery Update

The jQuery version included in a standard Drupal 7 distribution is 1.4. This version is quite old. There is a module jQuery Update which allows to use newer versions of  jQuery.

Friday, October 25, 2013

Installing Symfony2 Hello World on Windows XAMPP

This is not strictly about Drupal, but rather about installing Symfony2. Drupal 8 will use Symfony2 as a framework, so I'd like to take a look at Symfony itself and install a simple "hello world" project on Windows 7 XAMPP. The installation of Symfony with Drupal 8 will perhaps look differently.