Category Archives: Web Development

Create CSS rules with JavaScript

Here is the cross browser technique I use to create CSS on the fly with script. I use this method when I want to manipulate certain page elements with CSS, but only when the user has JavaScript enabled. I usually place this code just after the opening body tag. <script type="text/javascript"> /* <![CDATA[ */   [...]

Posted in Web Development | Tagged , , | 1 Comment

Target non-IE browsers with IE conditional comments

This is how you use IE conditional comments to target non-IE browsers: <!–[if !IE]><!–>This browser is NOT internet explorer<!–<![endif]–>

Posted in Web Development | Tagged , , | Leave a comment

Enable Symfony mailer with encryption

Configure your email in yourapp/config/factories.yml all: mailer: class: sfMailer param: transport: class: Swift_SmtpTransport param: host: mail.example.com port: 465 encryption: ssl username: yourname password: yourpassword And if you want email to work in the DEv environment: dev: mailer: param: delivery_strategy: realtime

Also posted in Symfony | Tagged , | Leave a comment

Magento template path hints in adminhtml

Template path hints are a great Magento feature to help you customise the frontend of your store. They can also be enabled for the admin backend. Override the app/code/core/Mage/Core/etc/system.xml file with the following. In my case I have put the override file in an extension app/code/local/Deanoj/Theme/etc/system.xml <?xml version="1.0"?> <config> <sections> <dev translate="label" module="core"> <groups> <debug [...]

Also posted in Magento | 3 Comments

htaccess Password Protection

Create an .htpasswd file for your login credentials: htpasswd -c .htpasswd someuser Create your .htaccess file: AuthUserFile /full/path/to/.htpasswd AuthType Basic AuthName "Protected Area" Require valid-user

Posted in Web Development | Tagged , , | Leave a comment

Configure xdebug for PHP

The xdebug extension can be found pre-compiled for windows, linux and OS X systems. http://code.activestate.com/komodo/remotedebugging/ Edit your PHP.ini file to enable the xdebug extension. Under windows: [xdebug] zend_extension=C:\software\php-5.3.2\ext\php_xdebug.dll

Also posted in PHP | Tagged , , | Leave a comment

Adding custom content blocks to Magento CMS pages

In this case I wanted to add a custom block containing the company contact details to the right sidebar on a CMS page. In the admin panel > CMS > ‘your page’ > design view, I set the Layout to a 3 column view. In the Layout Update XML I added a reference to my [...]

Also posted in Magento | 1 Comment

Basic CSS Template

A basic CSS template for use my barebones HTML layouts. /** * My main CSS * @author Your name dd/mm/yyyy * @requires reset.css */   /** ————————————————- layout **/     /** ————————————————- typography **/     /** ————————————————- forms **/     /** ————————————————- tables **/     /** ————————————————- lists **/

Posted in Web Development | Tagged , , | Leave a comment

Convert PHP unix timestamp to a MySQL date format

In PHP: $mysqldate = date( ‘Y-m-d H:i:s’, $unixdate ); $unixdate = strtotime( $mysqldate ); In the MySQL query: $query = "UPDATE table SET datetimefield = FROM_UNIXTIME($phpdate) WHERE…"; $query = "SELECT UNIX_TIMESTAMP(datetimefield) FROM table WHERE…";

Also posted in PHP | Tagged , | Leave a comment

Preserve PNG-32 Transparency using sfImageTransformPlugin

If you merge a PNG-32 (PNG format with an aplha channel) with another image, the transparent part of the original image will render with a solid black colour. The fix for this is quite simple. $bg = new sfImage(’main_image.jpg’); $bg = new sfImage(’blank_frame.png’); // has alpha channel $bg->transparency(’#000000′); // preserve alpha channel $bg->overlay($img, array(10,10)); The [...]

Also posted in Symfony | 1 Comment