Requirement: pre-filter products by customer group name to product attribute. I was looking for the “proper” way of filtering items by multiple custom attribute settings, but couldn’t find out how. So, the following is a brief explanation of how I’ve got this running in Magento 1.4.1. There are two ways of editing core code in [...]
Archive for the ‘Programming’ Category
White space trim for JavaScript
I originally blogged about this on my other site lazygnome.net but that was simply a quick place to record it. I present to you a very quick and handy way of replicating PHP’s trim() function in JS: function ws_trim(value) { return value.replace(/(^\s+|\s+$)/g, ”); } There it is, simple and usable. I don’t claim to [...]
writeAttribute() example
The documentation on http://prototypejs.org/api/element/writeAttribute is a wee bit scarce. So here’s a quick one on usage. To add an attribute: $(‘foo’).writeAttribute(‘title’, ‘bar’); To remove an attribute: $(‘foo’).writeAttribute(‘title’, null); To enable all disabled form elements (in a form with the id ‘container’): $(‘container’).select(‘[disabled="disabled"]‘).each(function(e) { $(e).writeAttribute(‘disabled’, null); });
Please, somebody standadise the order of function variables
Finding a needle in a haystack is a wonderful bit of symbolism and I welcome its use in many situations. It’s just the implementation of that symbolism that needs to be standardised. For forgetting the order in which a function expects variables to be passed in is tedious. In PHP, for example, there are some [...]

