By admin on February 15, 2010
As of PHP 5, objects with no properties are no longer considered empty. Therefore is you use empty() to test if an object is empty will always return true.
The easiest way to check for an empty object is to cast it to an array:
$objAsArray = (array)$object;
if ( empty( $objAsArray ) {...}
Incidently there are a lot of posts online about how to convert an array to an object. The quickest way is to cast it as an object:
$rs = array();
return (object)$rs;
Posted in PHP, Web Development | Tagged PHP
By admin on August 27, 2009
I have a Magento installation, with around 60 attribute sets. I needed to add a new attribute, and then add it to all the attribute sets. Doing this manually would take ages, and there didn’t seem to be a way of doing it through the API. I therefore created a PHP script to add the new attribute directly to the database.
Continue reading “Magento Batch Adding Attributes to Attribute Sets”
Posted in Magento, Web Development | Tagged Magento
By admin on August 26, 2009
Posted in Not so serious
By admin on August 26, 2009
Internet Explorer for Windows does not support the <abbr> tag. This makes it hard to style in CSS.
Marek Prokop posted a fix for this in the post Styling <abbr> in IE which has been very helpful. However, it seems to prevent JavaScript functioning properly.
Continue reading “Styling Abbr Tag in IE – JavaScript Fix”
Posted in Javascript, Web Development | Tagged HTML, Javascript, JQuery
By admin on July 28, 2009
I encountered an issue within Drupal with regards to admin and frontend themes. Specifically I needed to ensure that when a user creates or edits a particular type of content, it would remain in the frontend theme, and if they created or edited a different type, it would show in the admin theme.
Continue reading “Changing Drupal Theme on the Fly”
Posted in Web Development | Tagged Drupal
By admin on July 3, 2009
It is sometimes useful to programmatically load a view in Drupal, to execute it and then utilise the results. This is all straightforward and well documented. A little less documented is how to set the view arguements.
Continue reading “Drupal 6 – Views, programmatically set arguments”
Posted in Web Development | Tagged Drupal, PHP
By admin on June 17, 2009
Posted in Not so serious
By admin on June 17, 2009
Posted in Not so serious
By admin on March 24, 2009
Implementing WYSIWYG editing is fairly straightforward in Magento using either TinyMCE or FCKEditor. However, a known issue means that TinyMCE doesn’t work within the CMS section. So FCKEditor is the only real option at the moment.
There is however one issue to sort out. The product description field is mandatory; when you enter text into this field, and click ’save’ or ’save and continue’ the validation doesn’t pick the text up. You need to tell FCKEditor to update the textarea.
Continue reading “Magento FCKEditor Product Validation”
Posted in Javascript, Magento, PHP | Tagged FCKEditor, Magento
By admin on March 23, 2009
As with most things Magento, it isn’t too straightforward moving an installation from one domain to another.
I have provided this post as an outline on how to approach migrating your Magento installation.
Continue reading “Magento Migration”
Posted in Magento, PHP, Web Development | Tagged Magento