Web Development Archive

Automatic font resizing on iPhone / iPad

Our new company website has just gone live and on some pages the layout was broken on the iPhone and iPad. This was due to it’s minimum font size feature.

You can disable this by adding this to your CSS

div, p, a, li, td { -webkit-text-size-adjust:none; }

Strange problem when creatng Drupal 7 Module form_submit and db_update

Today we were creating a new custom module in Drupal and we had a form we had created and a submit handler. In the submit handler we had a db_update to update the row in the database. For ages we couldn’t find out why it wasn’t working until we noticed we’d set the update variables using

$form_state['values']['name']

This is wrong. This stores the values of the form fields as they were when the form was generated. To get the values of the fields as they were submitted, you need:

$form_state['input']['name']

One of those things that takes hours to spot! ARRRGGHH!!!

Removing “My Account” and “Logout” form header in Zen on Drupal

I’m just developing a new site in Drupal using the Zen STARTERKIT and it’s been a while since I’d done a design without the “My Account” and “Logout” links being needed in the header.

To get rid of them, simply go to admin/structure/menu/settings and change or remove a menu in the Secondary Menus.

Simples

Find and Replace in mySQL with PHPMyAdmin

I recently developed a Drupal powered site for a client on a test sub-domain. We then went live and everything was fine since Drupal doesn’t use the domain name in any links. The only problem was that the TinyMCE WYSIWYG editor we had used had put the sub-domain in the URL of some images they had included in various pages. Since I wanted to remove the test sub-domain as it was no longer needed and since it would prevent Google finding duplicate content, I wanted to remove any mention of it from the database.

Turns out that it you know the name of the fields and tables that could contain a mention of text you need to remove or replace, you can issue the below SQL to find and replace it.

UPDATE table SET field = REPLACE(field, "oldtext", "newtext");

If you aren’t sure which table or field could contain your text, since this is an SQL statement, you could use PHP and DESCRIBE TABLE or similar to run the command across every table and field in your database.

Using Innerfade in Drupal: Error $ is not a function

If you are trying to to implement Innerfade in Drupal having used it on standard HTML websites (ike I have) you may come across a few problems getting it working. Here’s a quick how-to to get it running.

Drupal (or WordPress), jQuery and $
You’ll find that when trying to insert jQuery into Drupal you get the JavaScript error

error $ is not a function

This is because some other libraries also use the $ sign and Drupal uses such libraries. Luckily jQuery can handle this so within your code, just replace $ with jQuery (see below).

Only including Innerfade on a single page
If you want to use Innerfade only on a single page as I did, you can create (or edit) the tpl fiel for that particular node and insert your code in there. If that makes no sense to, go to drupal.org and start reading.

Adding JavaScript to Drupal
The best way to add JS to Drupal is to use it’s core function drupal_add_js. This can save problems so use it.

Putting it all together
The below code is what I added to my node’s tpl between PHP tags. I then added the Div with the below ID using the node edit form and added the images too. Save / upload everything and you’re good to go.

drupal_add_js(base_path() . ‘sites/all/libraries/innerfade/jquery.innerfade.js’);
drupal_add_js(‘
jQuery(document).ready(function(){
jQuery(“#home-rotate-3″).innerfade({
speed: 1000,
timeout: 5000,
type: “sequence”,
containerheight: “398px”
});
});
‘, inline);

You will obviously need to download the innerfade js file and upload it to the above directory (or another of your choice) but it should work.

Outlook 2007 and Image Float

I’ve just designed some email templates and sent tests to the client who informed me that the images I had floated to the right of a paragraph of text were showing above the paragraph. A bit of digging turned up that Outlook 2007 has reverted to using Word 2007 as it’s HTML rendering engine which doesn’t support quite a few of the basics – one of which is the Float property.

What the hell. Since it’s no longer 1994 and we’re not using table based layouts, how are you supposed to do anything without Float? I know that M$ loves to ignore standards for it’s own rediculous business reasons but that is fucking stupid. Really stupid.

Luckily as per usual there is a work around for Microsoft stupidity and for once it’s not Mac OS X or Linux. Put this in your image tag:
align="right"
I hate Microsoft. I really, really do.

Drupal Webform – getting Date field using UK format

I’m working on a major project with Drupal – bigger than any I have done before so there’s obviously a bit of a learning curve to go through.

The latest problem was using the excellent Webform module. Although it works perfectly in my Drupal 7 install, all the dates are in the US mm/dd/yyyy format and I want the UK dd/mm/yyyy format.

All you have to do is go to Admin > Configuration > Date and Time and you can choose from a list of date and time formats to suit your needs.

Simples

New 1and1 Control Panel

After 1and1 rolled out a new version of their Cancellation Control Panel (http://contract.1and1.co.uk) they’ve now updated the design and functionality of the main Control Panel at http://my.1and1.co.uk – hopefully they will leave the old version available though at http://admin.1and1.co.uk as I can’t find anything any more!

The design is better but after they updated the Cancellation site, it didn’t work for me and I had to dig out the previous version so I could cancel some domains before their renewal date.

Hopefully this one will work well.

Tags: ,

How to clear the Facebook cache

If you’re using FBML or designing a Facebook App and you’re hosting a CSS, JavaScript or image file you’ll find that Facebook caches it on their servers and uses that copy in your App.

To get rid of the cached version while you’re developing. Add ?v=2 to the end of the file and then increment it when needed.

Planet Derby – Valentines

As mentioned previously we were working on a Valentines version of Planet Derby. Well it was ready for valentines day and you can have a go at Planet Derby : Valentines

It’s much better if you’ve got a webcam