try another color:

 
try another fontsize: tiny small normal big huge
netsperience 2.x
web development, web site design, seo and smo

prototype

jQuery to the Rescue! Drupal warning: Illegal offset type in isset or empty in user.module

Call me old fashioned. I started using JavaScript in the 90s before jQuery was even an idea. Sure, I can troubleshoot jQuery, and it is used a lot in Drupal, but my first impulse is to write regular JavaScript, which still works too. I think jQuery is the best JS framework, I've worked with prototype.js, mootools etc. too.

But when I wanted to hide an obscure and possibly meaningless warning message on the user account edit page (so that new members would not get freaked and think they did something wrong) I struggled.

First I hacked the user.module and although I removed the warning I also gave everybody admin access, including people who are not even logged in - not a good idea.

So I used CSS to hide the warning messages on "body-page.user" which seemed to do the trick.

Then my client told me he was having trouble creating new accounts, and I realized that I hid ALL user module warnings including "User name xxxx already exists" so I was back with the ugly warning.

Finally, I decided to hide just the warning with the text in question. Sure, I could have done it with classic JavaScript, indexing through all the div elements and looking for the matching innerHTML text and hiding the div. I guess that would have been about 8 lines of code.

I decided to figger out the best jQuery method. I came up with one line of jQuery code to add to my theme template that did the trick:

<script type="text/javascript">$("div.messages:contains('Illegal offset type in isset or empty')").hide();</script>

(note: the .messages selector is crucial; without it, all divs that are parents of the warning are also hidden, effectively hiding the entire page!)

jQuery: write less, do morethanks, jQuery...

now about that PHP warning...

learn jQuery at W3Schools

LinkedIn Behind-the-Scenes: JavaScript Frameworks

Ever wonder what JavaScript frameworks are powering LinkedIn?

The Framework Detector addon for Firefox can tell you:

JS Remoting Library, Prototype, Scriptaculous, Yahoo! UI Library

JavaScript frameworks in use on LinkedIn

and the Backend Software Information addon can detect Drupal 5.x, 6.x, Wordpress 2.x, Django, phpBB, MediaWiki, MoinMoin, Joomla, Reddit and more!

log in with your account on

Syndicate content