All posts by Vasyl Zhuk

Drupal 8 migration: taxonomy term lookups

By resorting to YAML files for configuration, Drupal 8 achieved a huge boost in flexibility and understandability of the parameters. Even more it is useful for such a “commonly uncommon” task as migration.

Indeed, in D7 you had a set of forms to match source to destination, using some limited set of processing options. Now, in D8, these three stages of migration are totally separated out, unleashing a (nearly) unlimited power of building processing pipes and referencing other migrations. Continue reading

Drupal 8: Views scrollTop behavior

Drupal 8 logoIt’s a weird piece of Drupal 8 out-of-the-box behavior: each time after you AJAX-load a views block with exposed filter, you are scrolled to the top of the block! It’s especially tiresome for mobile device users… Is there a way that we can fix it??

Removing this behavior entirely is a massive improvement. Here is a recipe to circumvent the issue for Drupal 7 – but it won’t work for Drupal 8! But search no more. Here for you is the exact solution:

Continue reading

Non-zero length redirects in Drupal

Drupal logoThose of you hosting Drupal sites on Acquia might come across this issue: enabling compressed cached pages leads to Varnish errors instead of redirects. As explained by Acquia support, this happens because Varnish tries to unzip zero-length response – and, naturally, then fails. Your options for solutions are to purchase a dedicated balancer configuration – or make the response non-zero (for instance, add the “Redirecting…” text into the body).

Continue reading

ANN in Python, JavaScript & PHP

Neural networks graphicNowadays you see artificial intelligence (AI) everywhere. It suggests search terms in search fields, recognizes faces on photos, targets ads, and even gives “personality” to your smartphone/tablet.

One of the most common types of AI is the artificial neural network (ANN). As long as full-fledged neural devices with computing parallelism are not yet commonly accessible, building one on conventional computer architectures is fairly easy. Due to the resource-heavy training algorithms required by the most ANN structures, including the popular Feed-Forward Back Propagation NN (FFBP), it is better to build core ANN functionalities in low-level languages. However, there are a few options for using scripting languages. This is a short survey for my favourite scripting languages: Python, JavaScript, and PHP.

Continue reading

Truncating text responsively

Truncated text is a pain...Are you trying to truncate text according to the space available? This is something you just cannot do in the back-end. That’s the truth – unless you are really crazy and have plenty of spare time. But even approaching text truncation in the front-end is not something achievable by writing a couple of simple CSS lines. In my opinion, one of the best approaches out there is the one offered by Andres Descalzo in this discussion over at StackOverflow. I took his method and modified it to match the needs of a responsively designed site. Here’s how it’s done…

Continue reading

Keeping your blocks straight

Drupal TipsDrupal 7 projects utilizing Contexts for placing blocks tend to grow quickly and have many, many different contexts – it can get really confusing! Utilizing a smart naming convention (like Phase 2’s) is an absolute must. But if you’re on a project with several developers, even a coherently, clearly named context structure can still cause headaches; you might still have to search and open up contexts one-by-one in order to locate a specific block.

For those of you using the Devel module, here’s a great way to increase efficiency and speed things up! Just use the following code snippet:

You can place this snippet anywhere in your code or go to http://www.your-local-site.com/devel/php to run it from there. In fact, you can use this snippet to search for all sorts of reactions – just modify the filtering options!

Storing sessions with Drupal

Drupal logoWhen developing a Web app with PHP, especially when using a framework or a CMS, most often you just don’t care about sessions. Less frequently, you store and access some information from a session, accessing it via language constructs (like “singleton” object (e.g. ZendSession  in Zend framework), some special wrapper functions or just $_SESSION  global). More often, though, you don’t bother monitoring how and where sessions are stored. But sometimes you should.

The basic purpose of this post is to talk about how, when developing a high-load website, to allow users to log on and access some personalized information. When you have hundreds of thousands hits per day, you should expect that tens of thousands users will log in to their respective accounts. That’s when you need to start caring about session storage. Continue reading

Beanstalkd + Drupal

The Beanstalkd homepageIn my last post I described how you make Drupal work with Gearman – a pretty good job server, which allows you to do things asynchronously, in the background. However cool Gearman is, there are a couple of downsides to the way it operates:

  • Its queueing protocol is too simplistic. Once you claim an item from the queue, you cannot release it (unless you create a client in a worker and add the identical item), postpone (bury), etc. So if the worker dies, the item is lost.
  • The Drupal integration module is sporadically maintained and still requires that you write quite a bit of code to get things working.

A great alternative is Beanstalkd. Written in C, it is super fast, and there is a PHP-written client – Pheanstalk – that provides for neat integration. Moreover, the Drupal module is actively maintained and has a full-fledged Drupal Queue backend class. Continue reading

Gearman + Drupal

Gearman logoTo say it simply, Gearman is a job server framework, allowing a site to execute some background processes in parallel – possibly even on different instances. Most likely you would only need this handy framework if you run a high-load website, especially if it is offering something more than just a blog functionality: automated email notifications, advanced gaming logic, etc. But even in a simpler setup you might find Gearman quite helpful.

Continue reading