Main menu

How to stop Drupal javascript behavior from executing several times

Published by dnovikov on Tue, 03/12/2013 - 17:23

Recently, during a new PopupAd module development, I've ran into a strange trap with Drupal Behaviors attach function. It executed infinite number of times:

(function ($) {

Drupal 7: Determine whether current theme is the admin theme

Published by dnovikov on Wed, 03/06/2013 - 16:05

If you want to check whether currently used theme is an admin one, use the following code snippet:

Drupal 7: Copying fields inside nodes using VBO

Published by dnovikov on Sat, 01/05/2013 - 18:38

I want to describe a good (and the most correct one in my opinion) way how to batch copy node field into another field of the same node. It should work also for any entities.

The topic of this article is covered here:, but with one exception - you need to know some basics of PHP to copy data between fileds. I want to show you some possibilities of copying data without a need to write a single line of code.

Drupal 7: Programmatically inject an arbitrary content into the view

Published by dnovikov on Fri, 04/27/2012 - 11:12

If you want to add something to the view, use

method. It can be a form for example:

Drupal 7 Form API: Inject a new field into a CCK fieldset

Published by dnovikov on Thu, 04/12/2012 - 15:27

Suppose, you have a node form with some predefined with admin interface fieldsets. If you need to inject a new field into one of these fieldsets, use such code snippet:

Microsoft SQL string padding technique

Published by dnovikov on Tue, 11/29/2011 - 12:08

Microsoft SQL has no functions for padding strings. This functionality can be only simulated. E.g., let's try to pad month number with leading zeroes:


SET @DT = '2003-02-02 10:31 PM'

SELECT RIGHT('0' + CAST(DATEPART(month, @DT) AS nvarchar), 2)

Installing Drupal 7 on IIS + SQLExpress results in error

Published by dnovikov on Mon, 10/10/2011 - 14:41

I've spent 3 or 4 days trying to fix the error (usually 500 HTTP or Drupal PDO exception "An error occurred substituting the named parameters"). I've tried a number of configurations, any PHP settings, different permissions and so on. I discovered only two ways which really fixed the problem:

1. Disable transactions in settings.php (set 'transactions' => FALSE in your DB settings).

Upgrading Solr 1.4.1 to 3.4.0

Published by dnovikov on Wed, 09/28/2011 - 10:10

You'll surely find a lot of deprecated WARNINGS in your output when start Solr. But the main issue I've faced after upgrading is change in schema.xml properties. For example, few HTML stripping classes were removed. You can read about this here. This is an excerpt:

Drupal: jQuery UI Datepicker "setDate" issue

Published by dnovikov on Tue, 09/13/2011 - 17:55

A lot of posts across the Web tell about issues with applying "setDate" function in jQuery UI Datepicker. In Drupal environment it is especially bad because you can't modify (or don't want to modify) source code used for datepicker instances initialisation. Here is a helper function which can save you from madness in some cases: