Hi gang, (semi off-topic..)

I just released a rather cool bit of PHP code inspired by jQuery.

In Drupal (drupal.org, CMS), our form structures (which govern user  
interaction) are built up as big trees of objects (group boxes,  
textfields, checkboxes, buttons, etc.). These arrays are a powerful  
tool to work with, as it becomes easy to insert new features in the  
middle of a form, for example to add 3rd party modules to the mix.  
They also help separate structure from user content.

Unfortunately, large tree structures can be cumbersome to use because  
you need to iterate over elements all the time. Sound familiar? Just  
like jQuery makes the clunky DOM elegant, my tool, fQuery, allows you  
to do use a CSS-like syntax to query the big arrays. It works like a  
charm and makes writing certain kinds of code much easier.

So, if you want all fieldsets on a page that are collapsible, you use  
"fieldset.collapsible". Finding textfields inside fieldsets becomes  
"fieldset > textfield". Checkboxes with a keyword matching in their  
label? "checkbox[#title*=keyword]".

Implementing a jQuery like query system has opened up a whole new way  
of dealing with forms in Drupal. It's a really cool technique. The  
best part is that it's relatively easy to adapt the code to custom  
structures, as the parsing is separate from the operators. It's easy  
to insert your own tree structure and define custom operators (e.g.  
filesystem queries where you use pathnames + filename meta data).

Has anyone else tried something like this? The jQuery architecture is  
definitely useful beyond DOM. I'm thinking if a bunch of people get  
together, we could make such custom "xQuery" systems easy to develop  
and use. I guess XPath is something similar, but I honestly don't  
know how much it's used ;).

Steven Wittens


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to