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


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.


Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen. logo

Je reageert onder je account. Log uit /  Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit /  Bijwerken )


Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )


Verbinden met %s