A HTML-Kit feature I never knew about!

While working on a site in HTML-Kit today I accidentally came across a feature that I really wish I knew about a long time ago.

I was happily coding away (oddly enough) in PHP and had highlighted a few lines of code that I wanted to move. Before I had the chance to move them I accidentally hit the tab button on the keyboard only to see all the highlighted lines get tabbed at once :eek:.

When I code in PHP I always indent the code like so:

if (isset($_POST['submit']))
{
	// do something
}
 else
{
	// do something else
}

I find it makes the code easier to read and easier to spot if I’m missing any closing brackets, etc.

Sometimes after I have written some code, I decide that I want to enclose it inside another statement or another loop. So I write the new statement or loop and then manually tab each line inside it so the code is formatted the way I like it. I’ve had to manually tab anywhere up to fifthy lines of code before. Not any more :D.

If only I had known about this feature a long time ago. It would have saved me a lot of time and frustration.

Advanced Bells & Whistles

Remember back to when you first learnt how to design web sites? Remember adding all those bells & whistles? I certainly do. Why did I add them? Because it seemed cool at the time.

The thing is… I’m still adding bells & whistles! Only now they’re more advanced bells & whistles.

Now that I know how to use the likes of Apache‘s mod_rewrite module or PHP‘s include function, I find myself wanting to make everything search engine friendly or use includes left, right and centre, when I should be keeping things simple. It’s a hard habit to break. When you know you can do something extra special – even though you probably don’t really need to – you find yourself doing it anyway… because it seems cool.

What’s worse is, these advanced bells & whistles can cause you more headaches than just keeping it simple.

Keep It Clean!

This year I received a christmas present I certainly wasn’t expecting. When my sister was shopping for presents she said she came across this and couldn’t resist buying it – as a joke – for me.

What is it, you ask?

A Computer Cleaning Vac, similar to this one. It’s a small handheld vac with a couple of attachments to help get into the nooks and crannies of the keyboard and mouse.

When I unwrapped it, I must admit it brought a chuckle. We have a very similar sense of humour, so she knew when buying it, that it would do exacting what she intended.

Nice one sis’ and thanks.

It hasn’t been put to the test just yet, but will be in the near future I’m sure :)

Automated Style Switcher

With the Christmas period upon us, I got to thinking… wouldn’t it be cool to be able to change the style of your site automatically depending on the time of the year?

Well with PHP it’s easy!

$today = date(′d/m′);
echo "<style type="text/css">";
echo "/*<![CDATA[*/";
if  ($today == ′25/12′)  {
echo "@import url(css/xmas_style.css);";
}  elseif ($today == ′01/01′)  {
echo "@import url(css/newyears_style.css);";
} else {
echo "@import url(css/style.css);";
}
echo "/*]]>*/";
echo "</style>";

First you assign a value to the $today variable using the date() function.

Then you echo out the beginning of the style tag. Then using a simple if…elseif…else statement you check if the value of the $today variable is equal to a certain date. If so, import the appropriate stylesheet. Finally you need to echo out the end of the style tag.

The code above needs to be placed inside the <head></head> tags in order to work. Also, this will only work properly on sites that have separated presentation from content.

Of course the code above only works on a day-to-day basis. If, for example, you wanted to have an xmas stylesheet be used for the entire month of December you would need to edit the code to check if the day falls between 01/12 – 31/12, but I’ll leave that up to you to figure out :)