try another color:

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

MooTools

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

FOB (Fly Over Background) DHTML Scroller

This scroller/viewer is similar to one using MooTools. It scrolls both the semi-transparent content divs to designated targets AND the optional background image, using smooth scrolling. The javascript source for this is lightweight, about 125 lines of code (5.73 kb) compared with about 10,000 lines in the MooTools-core and MooTools-more libraries (237 kb).

Feel free to use it. Please retain the copyleft GPL license notice intact.

Download files

 

log in with your account on

Syndicate content