Is Drupal’s l() function causing ‘operator not support for strings common.inc’?

Standaard

Previously I was confronted with an error while simply using the Drupal l() function. In this l() function I was trying to give the HTML a-tag a specific class attribute value. The following code was in my module:

l(‘some url text’, ‘the-path-for-the-current-active-page’, array(‘attributes’ => array(‘class’ => ‘custom-class’)))

When calling the page containing the link from above, I received the ‘operator not supported for strings’ error. It seemed that the l() function that at default tried to set the class attribute ‘active’, was causing the error. By removing the parameter for setting the class attribute, the problem got solved. My link now looks like:

l(‘some url text’, ‘the-path-for-the-current-active-page’)

This doesn’t cause any errors anymore.

Advertenties

Why is the mtime added in my Drupal module’s .info file?

Standaard

Since the Drupal Core update of version 7.34 all modules being updated contain an mtime text rule in the .info file.

This is caused by the Drupal core system.module file.

// Add the info file modification time, so it becomes available for
// contributed modules to use for ordering module lists.
$module->info[‘mtime’] = filemtime(dirname($module->uri) . ‘/’ . $module->name . ‘.info’);

How to remove branches in git that are no longer remote?

Standaard

git fetch -p

This does the magic, and unmerged local branches will not be removed.

Creating aliasses in Linux

Standaard

An alias in Linux gives you the possibility to shorten your command’s syntax.

For example, if you need to enter following code in your terminal to compile less code to css:

node less-watch-compiler.js less css

You can shorten this so you only need to enter the following code in your terminal:

less-watch-compiler less css

How do we do that? Simple, just follow the steps below:

  • Open /etc/profile in an editor
    • sudo nano /etc/profile
  • Add the following rule to your /etc/profile file
    • alias your-short-command-name=”the/command/directory/command parameter1 parameter2 …”
  • Exit and save your /etc/profile file
  • Execute “source /etc/profile”
  • That’s it

Based on the above example, I’ve added the next rule to /etc/profile:

alias less-watch-compiler=”node /Location/to/the/tool/Dead-Simple-LESS-Watch-Compiler/less-watch-compiler.js”