Consistent HTML Emails for Outlook compatibility

If you’ve ever had to send out emails to a marketing list or what have you, no doubt you’ve lost hair, pulling it out, and lost enamel grinding your teeth thanks to the worlds worst browser provider – Microsoft.

You should always remember the following:

  • Use old fashioned tables, not divs, for laying stuff out
  • dont include css, always use style=”whatever”
  • set cellspacing and cellpadding to 0
  • border=”0″ on your images with links
  • Use tables within tables, make your main table have one <td> in a row
  • if you are using colspan read the previous point
  • style your <a> tags or they’ll be that stinking default blue
  • following worldwide recognised and established coding standards will break outlook
  • Padding will screw up Outlook

The last point is the main reason IE etc is the worst, I have no idea why 13 or more years down the line they still cant get this right!
Padding for some stupid reason gets added to the outside of our box model rather than the inside. The best way to get round this? Shove a div inside whichever <td> you are in. Padding that will still screw up, so use margin instead.

If anyone else has any tips to spare the innocent developers from the Wrath of Gates, feel free to drop a comment!

And now for a short rant:

If you work for Microsoft, I hate you. Unless you convince whoever THE F*CK programs IE and Outlook to follow this link:

WRITTEN IN 1999 !!!!!!!!!!!!!!!!!

Moving a Live Magento Site to a Local Server


This job seems to get more interesting and fun by the day!

Today, it’s Magento! The mission? To move an existing Magento Store from Live hosting out there to another hosting provider, and then reskin it. And inbetween we’re going to miove it onto my local apache install.

Download the files, and setup your hosts and vhosts as per usual. However! localhost or whatever you call it will not be enough apparently, it likes a FQDN (fully qualified domain name.), so I called mine http://magentolab.del

Export the MySQL DB. Apparently the best way to do that is through the admin section of the magento site, as PHP MyAdmin does not bother with the Foreign Key Constraints of InnoDB, and you may get import errors if you do it that way. Your mileage may vary.

Import your SQL dump into MySQL, then run this command (your tables may or may not have the ‘mage_’ prefix, delete as appropriate)

select * from mage_core_config_data where path like "%base_url%"

Change the url to your local address. Put a trailing slash on the end of it!! Restart Apache, browse to your site, and watch it FAIL! Ok, now to set it up some more. Open it up in your favourite IDE, and look for app/etc/local.xml.
That’s where you’ll find settings regarding your DB connection. Edit to suit.

Now, you’ll probably not be getting to see your exceptions on screen. You’ll find them hidden away in var/report.

In my case, I was getting an exception that stated: Illegal scheme supplied, only alphanumeric characters are permitted

Again, the FQDN issue I described was part of this, but not all. We need to comment some other stuff out.
Dig into the app/code/core/Mage/Core/Model/Session/Abstract/ folder and open Varien.php. Jump to line 85 (as of v1.6.1)
Comment out some of the array like so:

  // session cookie params
        $cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath(),
          /*  'domain'   => $cookie->getConfigDomain(),
            'secure'   => $cookie->isSecure(),
            'httponly' => $cookie->getHttponly() */

If you’ve done everything correctly, you should have your live site running on your development machine! I’m guessing reverse that process to get it to my new live server! Have Fun

Setting the PATH environment variable for your executables on Mac OS X

Sure, you can cd /wherever/your/program/lies, then run ./program_name, but thats lame!

I just installed PEAR and PECL in work, and it went int /usr/local/pear. Pear itself was in /usr/local/pear/bin, so thats the path we need to add.

From your terminal:

cd ~
nano .profile

Once Nano opens (or vi, emacs, whatever you like using as your command line text editor), add the following, and thats it!

export PATH=/path/to/your/bin:/maybe/more/folders:/one/more/for/good/measure:$PATH

As you can see, you can add several paths in the one line, just separate them by a :

Remember to quit and reload your terminal!

ASP.NET Storefront for PHP People

Hi! This post will increase in size as the scale of horror increases, but for now, you’ve been landed with the runt of the projects – an ASP dot Net Storefront Website running on IIS on a windows server. Horrible!

Anyway, when not in the backend CMS part of things, you’ll have to edit files. What are they? I’m not entirely sure, but there are a few which I have figured out:

  • In the root folder there are appears to be categorynamehere.aspx (eg. watches.aspx). This is a landing page for a specific category
  • Header and Footer are in the Controls directory
  • Display Format Stuff and other bits of the header etc is in XMLPackages
  • In the backend, store admin > products > category, the displayformat xml package = entity.sortgridwithprices.xml
  • Also in the backend,  the actual product uses product.simpleproduct.xml.config
  • You can pick what categories each product comes under in the mappings tab.
  • Home Page template for some obscure reason is found in skins/Skin_2
  • Theres a cache flush link at the top right next to your logout link – use it!

Commands: In the xml.config files there are various output things such as {aspdnsf:GetUrl()}. I will document each as I figure them out

  • {aspdnsf:GetUrl()}  the url of the page, put this anywhere to output it
  • {$pName} the product name

Update: Today I’ve been asked to convert some products to ‘In store Only’! This basically means that you can’t order the product from the website, and instead need to call to book it. This is actually quite simple to achieve, all that is required is in Manage Products, you select the item,

*Is Call to Order: NoYes

Now when you visit the product page again, the add to cart button has been replaced!
Also, if we need to edit the actual topic page, to do this we go into Content > Manage Topics, select your topic, and use the wysiwyg editor!

Installing a ZendFramework App on IIS

Yes yes I know. Please. I’m just doing my job.

Anyway, hatred of MS and their less than satisfactory web based products aside, heres how to set up a Zend Framework App on IIS. I am assuming IIS is already up and running and that PHP is installed (only because thats where I started from)

Open IIS, in the computer click on Web Sites.
In the action menu click new website.
Put in a description, hit next.
Stick the servers IP in, port, and domain, hit next
Browse to sites home path hit next
Assign permissions (I had to browse to folder, right click and un-read-only my session, uploads, and logs folders), hit next, and finish.

Ok. Now IIS uses some thing thats similar to .htaccess, only it isn’t. Its called IIRF, and it needs setting up if it isn’t already. You can get it here: Download the Ionic’s ISAP Rewrite Filter (IIRF) here

Create Iirf.ini and shove this in it: (this took hours of farting around to get working :-s )

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^/(.*(\.js|\.swf)(\?.+))$ - [L,I]
RewriteRule ^/(.*(\.js|\.ico|\.gif|\.jpg|\.png|\.css|\.html|\.htm|\.swf|\.flv))$ /$1 [L,I]
RewriteRule ^/(.*)$ /index.php/$1 [L,I]

Put this in your Zend Apps public folder. Note that the commented out rule is for ignoring css js and image files etc in your public folder so as not to get rewritten. However it messes with your GET parameters when you have a filename in the query.(IF anyone knows how to write a rule that say continue to route it if those extensions come after a question mark then PLEASE let me know!)

Restart IIS, and that should be you!

NB. Neither delboy1978uk nor anyone else endorses the use of IIS for any serious web development.

NB. I have found normal clean urls work but ?query=param gets dont! i will update once i fix this!