Category Archives: Web Design

Fixing Youtube iframe overlay issues

Español: Logo Vectorial de YouTube
Image via Wikipedia

I’ve got a website that displays iframe embedded Youtube videos and uses Lightbox to load images up, however, the images load behind the virool review Youtube video. I’ve come across this before on other websites but not on any of my own. I fiddled around with z-indexes for a bit but they didn’t do anything. Turns out, it’s actually a very easy fix. Just add ?wmode=opaque to the src address in the iframe.

For example:

<iframe width=”560″ height=”315″ src=”http://www.youtube.com/embed/hTCAeGIBaxw” frameborder=”0″ allowfullscreen></iframe>

Becomes:

<iframe width=”560″ height=”315″ src=”http://www.youtube.com/embed/hTCAeGIBaxw?wmode=opaque” frameborder=”0″ allowfullscreen></iframe>

Super easy!

I also came across this video by 360 Creations explaining it:

From what I read, ?wmode=transparent should work as well, but it sounds like it is a bit slower to render as it has to render transparency, opaque renders solid. It would be great if Youtube included this in the src address by default! It would make it so much easier for everyone.

Enhanced by Zemanta

Internet Explorer Truncates Long CSS Files

I came across an interesting quirk in Internet Explorer a couple of days ago whilst working on a project for a client.

There is a section on their website that has an extensive set of stylesheets that is around 3,500 lines long. Combined with the stylesheets for the rest of the website, the total is about 6,500 lines.

The design was all finished and looked great in Firefox, Chrome, Opera, IE 7 and IE 8. However, then I did up the set of styles I mentioned that ended up totalling 3,500 lines. Due to the way I lay out my stylesheets, these started at about line 2,000. Which meant about 1,000 lines were after them.

While I’m working on something new I test in Firefox with Firebug and then once I’m finished I adjust for IE. So all of a sudden when I tested in IE 7 and 8, they are not displaying things correctly, including things in the design that were working previously. Using IE’s built in developer tools I was able to see that there were stylesheets simply not being applied to things that they should have been after about the 4,500 – 5,000 line mark. The entire stylsheet was loaded though and could be viewed.

I began tweaking things in the IE specific stylesheet since I couldn’t get it to work by editing the regular stylesheet. Once I realised that I could copy things directly from the main stylesheet into the IE one and it worked without tweaking, I started to think something odd was going on.

Cutting the extra 3,500 lines out put the site back to normal in IE, except for what those things affected.

If I put those lines in a separate stylesheet, everything worked perfectly fine again.

So it seems to me that for some reason IE just will not read more than around 4,500 to 5,000 lines in a stylesheet. It could perhaps also be total characters, however I didn’t test to find at exactly what point it stopped reading so I can’t be sure.  Fortunately, simply adding in an extra stylesheet did solve the problem, and given the nature of the extra CSS, it probably should have been done that way in the first place so that it could be loaded solely on the pages that actually need it. It should be noted that the total lines are still the same, they are just split between two stylesheets now, one of which is only loaded on certain pages.

I did a quick search for this but didn’t really come up with anything similar elsewhere, so if you have had a similar issue, I would love to hear about it!

It seemed to be consistently about the same place in both IE7 and IE8, so hopefully it won’t find it’s way into IE9.

Finding The Path To Your Drupal Theme

Ever needed to reference a file in your Drupal theme? For example, an image from your page.tpl.php file, or a JavaScript file?

You can hard code the path, which might be something like:

/sites/all/themes/mytheme/images/myimage.jpg

Or, with a little bit of PHP, you can use Drupal’s built in path_to_theme() function. This function will print out the path to your Drupal theme from the root directory.

So, in your theme you might have this image, but instead of writing:

<img src=”/sites/all/themes/mytheme/images/myimage.jpg” alt=”My Awesome Image” />

You could write:

<img src=”/<?php print path_to_theme(); ?>/images/myimage.jpg” alt=”My Awesome Image” />

At first glance it is slightly longer and might seem like more effort to do. Think of it a bit differently though. What if you want to rename your theme, or use your theme on a different domain name? You will need to change the hardcoded path. By using Drupal’s path_to_theme() function, it will dynamically figure out the path to your theme directory for you.

We can then take this a bit further with Drupal’s base_path() function. This particular function returns the path to the base Drupal installation. If you have it installed in the root directory of your hosting account, then this will simply be a /.

The real benefit of this is if your Drupal installation is in a different directory. For example, /drupal. If this is the case, then your hard coded path would be /drupal/sites/all/themes/mytheme/images/myimage.jpg the path_to_theme() function will still only return /sites/all/themes/mytheme though, and the browser will not be able to find your image. The reason for this is that it only determines the path from the base installation directory of Drupal. So, to make sure your theme is truly dynamic and capable of dealing with this, you would use something like this:

<img src=”<?php print base_path() . path_to_theme(); ?>/images/myimage.jpg” alt=”My Awesome Image” />

Now if you have Drupal installed in a sub-directory called Drupal, this would actually return the full path we need: /drupal/sites/all/themes/mytheme

One thing to remember if you use this is that the path_to_theme() function doesn’t put in a trailing / or start off with a / so you will need to put these in before adding in the rest of your files location. Comparatively though, base_path() does add a / both before and after the path. So if you use it, you will not need to prefix it with a /.

This works in Drupal 5 and 6, and I believe is going to continue to function the same way in Drupal 7, so your themes will be all set to work on any server without needing to adjust the file paths. Give it a try!

You can also have a look at these functions in the Drupal API documentation:

Placing Adsense After Your First WordPress Post

Google Adsense is a great way to make some money off of your blog, and by placing your code in a couple of key places in your template files, you can have it automatically displayed on all of your blog posts. One thing to keep in mind though is that you can only show 3 ads per page, any more than that and in most browsers an empty space will be left, which is to some extent ok, but in other browsers it can appear as a broken iframe or image. While an empty space isn’t ideal, it can be acceptable, a broken section on your site really isn’t.

It’s for this reason that most people will set up their template to only display Adsense code on the first post shown on each page where multiple posts are displayed. For example on your index page, category pages, tag pages and archive pages.

So to ensure that your Adsense code only displays once you need a way to make sure that when WordPress loops through each post, there is some way for it to figure out whether or not it’s the first post. Joe over at joehayes.org has written a great post about doing this.

Somewhere before the start of the WordPress loop, you need a base way to count. Joe has done this by placing the following code:

<?php $count = 1; ?>

Before the WordPress loop which starts off with:

<?php if (have_posts())

Then inside the content section of the loop which starts off with:

<?php the_content

You need to decide whereabouts you are going to put your Adsense code. Paste it in somewhere, this could be before or after the post content, or after the meta information, or anywhere else that be suit your particular template.

Now, just before the start of your Adsense code you need a way to check the number of posts. We’ll use some PHP to check the $count number that we set earlier.

<?php if ($count == 1) : ?>

This checks to make sure it is still 1. If it is, then your Adsense code will be displayed. If not then it won’t be.

Directly after your Adsense code we then need a way to make sure that the other posts don’t also appear as number 1.

<?php endif; $count++; ?>

This section of PHP tells WordPress to add 1 to the counter. So the next time WordPress runs through the loop, it will be a 2 instead, and it will go 1 higher for each post, so only the first post will appear as 1, thus only the first post will show the Adsense code.

It’s pretty simple but it does the trick very well!

If you wanted to display 2 or 3 ads, one on each of the first 2 or 3 pages, you could simply change the PHP around a little bit.

<?php if ($count <= 3) : ?>

The above snippet for example tells WordPress that if the count number is 3 or lower, than it should display the Adsense code with only 2 minor changes to the original code.

Don’t Settle For Less

I get emails from a website called Service Seeking when there is a job listed that is related to my field of work, specifically web design. I have practically given up on it though as there seem to be a number of firms on there now that come in with quote on under $1000 on pretty much every job, including jobs that I cannot see any way possible to do for under $6000 unless those working on it are paid around the $2 an hour mark. It’s just not possible.

I find firms that offer quotes like this to be degrading, they devalue the job and the designer. The brand image should be an important part of any business. A business should be willing to recognise that they need to spend money to get a job done well. Once it’s devalued, it can be difficult to help customers realise that our time as designers is valuable, that we are in control of how their business looks online and that subsequently if we are undervalued, we cannot make their business look good.

There was one new job listing posted today that reads:

“Hi, I am currently in the process of putting together my own … business and as I am still in the researching stage I am just simply after quotes so that when I am ready to hire in a few months I know exactly who to call. I am after a company that can build my … site exactly to my needs, be easy and helpful to work with, fast and can also host my website for me. I expect to pay no more then $1000 if not less and would like my website to be put together in a couple of weeks as when I am ready to go I want to get up and running asap.”

I’ve edited out a couple of points that may make this business identifiable, but what they are asking for here is pretty unrealistic. Part of one point that I had to remove is that they are after e-commerce functionality as they need to be selling things online. They want it for under $1000 AND done in a matter of weeks. Basically it’s a case of wanting the world for nothing, which is becoming all too common in web design. Let’s break it down and look at it more closely.

Let’s say we use Drupal for the content management system on this project with Ubercart handling the e-commerce side of things.

  • Installation of Drupal with Ubercart and other required modules could be done in about half an hour.
  • Customisation and testing of Drupal, Ubercart and other settings could take anywhere from an hour upwards. In my experience it averages at 5-10 hours.
  • Setting up and testing Ubercart with PayPal could take half an hour to an hour.
  • Doing up the graphics for a design with a customer that sounds like they are going to be picky could be anywhere from 2 hours to 15 hours.
  • Converting the graphic design to a Drupal template using another template such as Framework to form the basis of the design could be 5 to 15 hours as well depending on complexity of the design, not to mention ensuring that it suits the e-commerce side of things as well.
  • Consultation times, could vary from 1 to 10 hours.
  • Miscellaneous extra 1 to 15 hours.
  • Total minimum: 15 hours work.
  • More likely minimum: 40 hours work.

At an average rate of $85 per hour, that’s an absolute minimum of $1275, but more likely $3400. That’s still a cheap e-commerce website, and costs more than 3 times the amount they want it for. Most e-commerce sites that I have worked on have been around the 50-60 hour mark or higher. By devaluing the market, clients don’t realise just how much they need to invest in this sort of thing.

Compare it to radio or TV advertising where advertisers will unquestioningly pay $5000 upwards on advertising campaigns, many looking at over $20,000 for one campaign, it’s a big difference, especially considering your website is advertising for you 24/7 compared to your TV or radio advertisement that’s only 30 seconds or so here and there!

One thing to keep in mind is that you always get what you pay for and you certainly cannot get the world for nothing. Don’t get me wrong, there are some quality designers that have specials and do quality work for cheap. In the end though you need to analyse what you need and be prepared to pay for it. You don’t have to pay top dollar, just ensure that what you are paying for is what you really want.

A final example to leave you with. I had one client previously whom I quoted for. They decided to go with another group who quoted them about a fifth of what I did. After the other group completed the website, I thought I should point out to the client the (numerous) accessibility issues with any non-IE7/8 browser. By the time they had paid the other group to get everything right, they ended up paying more than what I had quoted them in the first place, so paying a bit more to start off with would have saved them both time and money, and potentially saved them on any damage to their reputation that the poorly designed website could have caused.

Investigate your options and make an informed decision, don’t just go with what seems to be the cheapest.

CSS Clip Property

I recently came across the clip property on the Web Designer Wall, it’s a property I’ve not heard of before, probably because I’ve not really had a need for it, but now that I know what it does, there are so many things it would save time with!

The example below is an excerpt from the Web Designer Wall:

.clip {
 position: relative;
 height: 130px;
 width: 200px;
 border: solid 1px #ccc;
}
.clip img {
 position: absolute;
 clip: rect(30px 165px 100px 30px);
}

How it works is you have a surrounding element, such as a div or li which sets the overall width and a border which gives the appearance of masking the image. It also sets the position of relative so that on the img tag, we can absolutely position it within the outer element.

The img tag is then set to position: absolute; with a clip property that clips the image to a rectangle shape (so it can also be a square).

The uses of this property are potentially huge, especially for image galleries, and you can also resize images by specifying the width and height on the img tag. Perfect for a gallery, as long as the images you are scaling aren’t huge, you don’t want images that appear small ot take a long time to load after all!

The big downside of this is that according to the SitePoint CSS reference, Internet Explorer up to and including version 7 do not fully support it, so you may need to use a variation on the syntax especially for Internet Explorer. The way I understand it,  you just need to use spaces instead of commas in the rect() syntax for Internet Explorer, but I haven’t had a chance to test this yet to be sure.

Even if it doesn’t work fully in Internet Explorer, you could easily implement it in a way that will gracefully degrade in IE.

I’m looking forward to using this property, have you used it on one of your sites? I’d love to see how you’re using it, let me know in the comments!

Embed Flash video in valid XHTML

Getting a Flash video to embed in an XHTML strict document without breaking validity is something that has always been a frustration to me, as I aim for every website I build to be written so that it validates and is the most search engine friendly. After a bit of a hunt around, I came across this code snippet from Yoast.

Basically, the key is the <embed> tag that usually gets used. It’s not valid and it turns out, it’s not actually needed. So basically, you want something that looks like:

<object type="application/x-shockwave-flash"
	data="music/sound.swf"
	width="0" height="0">
	<param name="movie" value="music/sound.swf" />
	<param name="quality" value="high"/>
</object>

Thats basically it, just change the width and height to the dimensions you need and change the path in object and in the movie parameter. There you go.

As Yoast indicates, this doesn’t automatically update the Flash player for clients if a new version is needed, but thats fine for my purposes at the moment. You would need to add in a codebase attribute to the object tag in order to have it automatically check, but I think thats for another time.

Experimenting with Landing Pages

At TerraMedia, I am currently working on an interesting project. That is, I am working on pushing the website up in search results for a number of different regions.

One of the ones I am working on at the moment is users searching for  web site design and related services in the Byron Bay region. If you do a quick search in Google for “web design Byron Bay” or “Byron Bay web design” or similar, TerraMedia cannot be found on the first page of results. The home page of TerraMedia is visible on the second page in the case of both those queries, but we would like it high up on the first.

There are a couple of places to start here, the first is to update the home page to more specifically target Byron Bay, or, to create a landing page which is optimised for Byron Bay searches. We don’t really want to adjust the home page too extensively as it is currently placed quite well for a number of other regions, so we decided to begin with landing pages, starting with Byron Bay.

To start off with, I have setup a new page on the TerraMedia web site that has all of the keywords we are looking for in both the page title and the page address. The page that I have set up is located at http://terramedia.com.au/web-site-design-services-byron-bay and uses some new copy that is based on copy used in other sections of the website combined with some newly written information to help target potential Byron Bay clients.

A sub-domain or domain that is specifically relevant to these terms may be easier to rank higher, but at the same time, they would lose the benefit of being on the terramedia.com.au domain and could confuse the user in the case of a completely different domain name. Wouldn’t you be confused if you went from say “websitedesignservicesinbyronbay.com” to “terramedia.com.au”? That domain is an exaggerated example and is much too long, but I’m sure you can see how it could get confusing.

Now that the page is created I will be developing links to it and marketing it through our Facebook page and Twitter account.I want to get twitter followers for our page to see how it goes. The aim is then to push this page up in search results specifically regarding web site design in the Byron Bay region.

Search Engine Optimisation for a WordPress Client

TerraMedia has recently been contracted to work on fixing up a WordPress website, specifically looking at improving usability and search engine optimisation.

There are a few key things that I will be doing on their website as part of this job.

The first thing I have done is to implement Google Analytics tracking code so that we can begin to get an idea of how people are finding the website. This will track visits while I am working on other sections of the website so that we can get a few weeks worth of results without having to wait idly for them.

There have been reported issues of the navigation not functioning correctly in all browsers, particularly Internet Explorer. As the navigation is vital to accessing website content, it is important to get this working correctly as soon as possible.

Next up I will be updating and modifying the template to help meet both of the criteria by ensuring the markup makes semantic sense, including adding in hierarchical header tags to each page. At the moment, while these are used, each page lacks its own heading, meaning that it is harder for search engines to determine the relevance of individual pages and their content, and users cannot easily see what each page is about.

Once I’ve got the code cleaned up so that is more search engine friendly and the front end more usable, we will start focusing more heavily on getting more traffic to the website from both search engines and other sources, more customers is the primary goal after all!

I will be installing a WordPress plugin called the All In One SEO Pack, which will allow us to specify page titles and meta tags for each page and blog post individually, allowing the keywords and descriptions to be optimised for each page. It also gives better control over the overall meta tags, and tags for archives, categories and so on.

They currently do not have any introductory text on their home page, this means that the root page of their domain name (arguably one of the most important pages of a website from a search perspective) doesn’t really tell search engines anything. It has photos, events, a logo and the navigation. So what we will be doing here is writing up a paragraph or two of highly optimised copy. By this point we should have about a months worth of results from Google Analytics so once this is implemented we will be able to clearly see the difference this text will make and subsequently tweak it as necessary.

To keep the home page fresh and keep the search engines checking it regularly, we will also be having the latest blog post displayed on the home page. As part of this, the client will also begin using WordPress’s blogging functionality to keep the website up to date with the latest news and special offers. They currently do not utilise this functionality, which is a big opportunity to keep their potential customers up to date.

Finally, we will be implementing a sitemap which will be submitted to search engines on a regular basis so that new blog posts and updated pages will be updated in their indexes as soon as possible.

By this point, we should be seeing quite an improvement in search engine rankings and subsequently in website traffic. In order to capitalise on this increased traffic, we will be adding in a static widget that shows the contact details on every page of the website and provides a link to the contact form. This will make it as easy as possible for potential customers to get more information or to make a booking. We will also be making the RSS feed a prominent link on each page to encourage visitors that use an RSS reader to subscribe to the latest updates and specials, and subsequently draw visitors back for potential future and/or repeat sales.

It’s overall a simple but interesting project that will pretty quickly show the difference a well optimised website that is regularyl updated can make. From here, we will start looking at building up links in directories and other relevant websites to continue to improve search rankings and visitor access points.