How to make your background image as big as possible

By Tim Priebe on September 5, 2011 at 7:40 am in How-To,Technical

One example of a full-screen site

Hey, everyone! Time for a technical tip for those tweaking their website on their own. If that’s not you, feel free to skip this blog.

One cool way to use photography on your site is to have a photo set as the background image on your home page, and have it take up the whole background space, resizing to be bigger as you make your browser bigger (or smaller). Don’t trust me? Check out 75 cool websites using full screen photo backgrounds for yourself.

How is this accomplished? Well, traditionally there was some JavaScript hacking necessary. Fortunately, with CSS3, the solution is now much simpler. Here is some sample code:

body {
background-attachment: fixed;
background-image: url(my-background-image.jpg);
background-origin: content-box;
background-position: center center;
background-repeat: no-repeat;
-o-background-size: 100% 100%;
-moz-background-size: 100% 100%;
-webkit-background-size: 100% 100%;
background-size: 100% 100%;
}

Of course, this doesn’t work right in versions of Internet Explorer before 9, so if you want to support that as well, you’ll have to use some jQuery trickery.

Email Etiquette Part 3: Dealing with those Cc’s and Bcc’s

By Adam Booth on October 19, 2010 at 9:24 am in Email,Technical

emailetiquette2We send and receive emails all day, but does everyone really know about some of the extra options for sending out emails?

Unless you’ve been living under a rock for the past couple years, I would hope that it’s safe to assume that you understand what should go in the “To:” and “Subject:” fields, so I won’t dig too deep into either of those options.

In this post, I’m going to address how to properly use the Cc and Bcc fields. Many people are aware of these fields, but they are often misused. Although email etiquette doesn’t seem like a big deal, I think it’s important to address some of these problems for our everyday sanity as well as security issues that can potentially arise.

“Cc:” field or “Carbon Copy”

This is used to include other people in an email even if the email is not necessarily intended for them specifically.

emailetiquette-cc2For example, if I send an email saying, “Hey we miss you!” to a far away friend, I could CC all of my other friends who might also feel the same way so that they are included and are aware that I sent the email.

Our far away friend would be able to see that I Cc’d all of our friends and would have the option of replying to only me or choosing “reply all”, which would be delivered to my inbox as well as everyone else Cc’d.

It is also worth mentioning that it is proper etiquette for the recipient to “reply all” so that all people CC’d also receive their reply. This keeps everyone updated at all times and cuts out steps of having to resend emails to people who didn’t receive it.

“Bcc:” field or “Blind Carbon Copy”

emailetiquette-bccThis is very similar to Cc except for one major difference: the recipient would not be able to see the other friends included in the email.

This is much more secretive because there is no way for the recipient of this email to see who all was included. Because they have no way of knowing who all was included in the email, they are unable to choose the “reply all” option and can only reply to the sender.

Bcc definitely has its perks, but should be used tastefully and not to “spy” on people. It can, however, be used for security purposes when forwarding messages. Instead of Cc’ing your whole address book when you forward a message, you can put them in the Bcc field to keep their email addresses private from spammers. For more information on this, visit here.

Hopefully this has been fairly helpful to those of you who were wondering about some of the finer details of how sending emails work. If you’d like to learn even more about email etiquette, be sure to check out these other great posts here and here. Cheers!

Making WordPress page headings different from the menu items

By Tim Priebe on May 17, 2010 at 7:48 am in Development,Technical

PHP and WordPressJust a quick WordPress tip this time for theme developers, or people who just want to customize a WordPress theme they’ve purchased.

Sometimes there are reasons to make a menu item slightly different from the title of the actual page. Perhaps your menu space is limited, but you have plenty of room in the content area. A typical example is using “FAQ” in the menu, but then the page heading actually shows “Frequently Asked Questions.”

A great way to accomplish this is the Custom Fields in WordPress, combined with a bit of theme customization.

Normally, you would insert the title of a page like this:

<?php the_title(); ?>

Instead, you can create a custom field. We’ll call it “custompagetitle” for this example. On the FAQ page, you would enter ‘FAQ” as the title of the page, then a custom field called “custompagetitle” and enter “Frequently Asked Questions” there. Then, instead of the previously mentioned code, insert this code:

<?php

// See if there's a custom field custompagetitle,
// and if so, use it as the page's title

$realtitles = get_post_custom_values('custompagetitle');

if (is_array($realtitles)) {

$realtitle = implode($realtitles);

}

if ($realtitle)

echo $realtitle;

else

the_title();

?>

Not only does this code use your custom heading, but if there is no custom heading, it will default to the actual page title.

Preventing jQuery conflicts in WordPress

By Sean Sanders on March 30, 2010 at 4:36 pm in Development,Technical

jquery

Okay, it’s programming pet peeve time. Well, specifically web programming pet peeves. And really just one, so forget the plural there. Here goes nothing.

If you do any kind of web programming at all, you’ll have heard of jQuery, which is (according to this source: http://trends.builtwith.com/javascript/JQuery) the most popular Javascript library in use today. It’s got several things going for it. It’s powerful. It’s flexible. It’s easy to use. It’ll even clean your house and do your dishes if you ask nicely. OK, maybe not that last one, but I’m sure it will be in a future release.

Being as powerful as it is, it comes as no surprise that a large number of WordPress plugins use jQuery for all kinds of things. If you are a theme or plugin developer chances are you will frequently make use of jQuery in this development process.

The problem with so many developers using jQuery is using the traditional method of including it can cause conflicts between versions. Typically, you would load jQuery in one of a couple of ways.

If you have a local copy:

<script type="text/javascript" src="_js/jquery.js"> </script>

Or if you prefer Google’s CDN (Content Distribution Network) version:

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”></script>

The problem with directly placing these in your theme’s header, or using the add_action function as a plugin writer, is yours is likely not the only part of the end-user’s WordPress installation which will want to use jQuery. If you have multiple places in the website trying to load jQuery you end up with at best redundancy in your code and at worst a conflict which breaks your website.

Fortunately, if you want to use jQuery without causing conflicts then WordPress will do of the work for you. WordPress already includes its own version of jQuery, so if you’re happy with using the included version, all you need is this php function:

<?php wp_enqueue_script('jquery'); ?>

WordPress inserts all the queued scripts during the wp_head hook, so you need to call this function before that hook runs. If you’re a theme developer, it’s sufficient to insert this function call anywhere in your head section (assuming you follow the practice of always placing wp_head() at the end). If you’re a plugin developer, you’ll need to make use of the init hook.

<?php
	function my_init_method() {
		wp_enqueue_script('jquery');
	}
add_action('init', 'my_init_method');
?>

This will make sure the script is queued before wp_head is run. Now say you don’t like WordPress’s included version and would instead like to use a different version. Here is how you would change it to use the CDN version:

<?php
function my_init_method() {
	wp_deregister_script( 'jquery' );
		wp_register_script(   'jquery',
		'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js');
	wp_enqueue_script(‘jquery’);
}
add_action('init', 'my_init_method');
?>

One last thing to note: WordPress loads jQuery in “no conflict” mode. A good description of the details of this mode are available here: http://api.jquery.com/jQuery.noConflict/. What this means for most users is just you’ll want to use the jQuery alias instead of the normal shortcut of $. This is to prevent conflicts with other scripts which use the same shortcut. Instead of looking like this:

$(‘.lameClass’).addClass(‘awesomeClass’);

Your code will look like this:

jQuery(‘.lameClass’).addClass(‘awesomeClass’);

You can see that WordPress has built in the capability to handle pretty much any scenario you could come across; you can even load different versions of jQuery and give them different aliases if you really need to. So now that everybody knows, I’m not going to see any more jQuery conflicts in WordPress. Right? Please?

You can find more information on queueing scripts and a list of plugins WordPress has handles for in the WordPress codex at http://codex.wordpress.org/Function_Reference/wp_enqueue_script.

Alternating column colors with jQuery

By Tim Priebe on January 4, 2010 at 7:04 pm in css,Design,html,Technical

jquery-tablesWe recently had one of our designers create a table design for a client with alternating column colors. Instead of laughing at her and not coding it, we instead decided to use a little jQuery goodness to get it taken care of.

We included the following code in our document’s head, using the Google jQuery implementation:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1.3.2");

google.setOnLoadCallback(function() {
$("table tr td:nth-child(even)").addClass("even-column");
$("table tr th:nth-child(even)").addClass("even-column");
});
</script>

So that’s the code that gives every other table cell, including header cells, the class of even-column. Now we can style those cells however we’d like.

In our case, a little CSS transformed the table pictured below on the left into the table on the right.

screen-shot-2010-01-04-at-64457-pm screen-shot-2010-01-04-at-64510-pm

Of course, putting the following in our google.setOnLoadCallback function will do something similar for rows.

$("table tr:nth-child(even) td").addClass("even-column");

This would result in the following:

screen-shot-2010-01-04-at-64554-pm

While this could have been solved by actually hard-coding the table’s cells with the even-column class, we are using WordPress on this site. This means the client could add their own table on down the line, having no idea what a class is, much less to add a specific one to every other cell in every row of the table. Plus, that would be a lot of work.

Demo of WordPress Plugins 1/3

By Tim Priebe on December 16, 2009 at 6:32 am in Technical,Video

Recently at a local WordPress Users’ Group, I discussed some of our favorite WordPress Plugins here at T&S Web Design. Check out part 1/3 below, with Contact Form 7. Parts 2 & 3 coming soon…

Tip for IE6 fixes in Dreamweaver

By Tim Priebe on November 27, 2009 at 5:03 pm in css,How-To,Technical

Dreamweaver and conditional IE6 CSSIf you’re a Dreamweaver user and you try to make sure your sites work in Internet Explorer 6, this tip is for you.

When using Dreamweaver templates, one of the things that Dreamweaver does well is automatically correct paths for you. This is extremely helpful, because you don’t have to worry about what directory you’re in when linking to files.

So you might link to a style sheet in your template Templates/main.dwt like this:

<link href="../_css/reset.css" rel="stylesheet" type="text/css" />

Then, when you look at a file index.php one directory up, it looks like this:

<link href="_css/reset.css" rel="stylesheet" type="text/css" />

Or, in a file /misc/news/index.php, it looks like this:

<link href="../../_css/reset.css" rel="stylesheet" type="text/css" />

Internet Explorer 6 often requires several CSS fixes to get your website to look like it does in other browsers. The method I personally prefer (and that we use at T&S) is a separate CSS file for IE6 that’s applied only when IE6 is used.

Here’s what that looks like:

<!--[if lte IE 6]>
<link href="_css/ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->

The only problem when using this technique in Dreamweaver-based sites is that Dreamweaver sees the entire thing as an HTML comment, and therefore does not update the CSS file’s path when it’s in a different folder. So it might work in some files, and not in others.

If your files are PHP files, there’s a workaround. You can use the following code:

<?php echo "<!--[if lte IE 6]>\n"; ?>
<link href="_css/ie6.css" rel="stylesheet" type="text/css" />
<?php echo "<![endif]-->\n"; ?>

And there you go. Now Dreamweaver will skip over the PHP code, and will assume that the IE6 stylesheet is just a normally linked stylesheet. Your browser will interpret the code correctly, but Dreamweaver will still update the path for you.

Firebug in IE

By Sean Sanders on October 20, 2009 at 6:50 am in css,Development,html,Technical

firebug-logoI’m Sean Sanders, one of the relatively new programmers here at T&S. Our former programmer Nick Little blogged previously about tools to help with web development, and one of those tools I find incredibly useful is the Firebug plugin for Firefox. There are some situations when having the ability to look at the CSS in other browsers the way you can in Firefox is helpful.  This is especially true with IE. Because of the way IE chooses to (not) display CSS rules, we often have to create style sheets just for IE to make it display our sites properly. A few days ago I found myself in a situation where I was trying to debug a site in IE7 and wanted to figure out exactly which rules were being applied. I looked into seeing if there was a way to use Firebug in IE.

What I found was a short bit of Javascript the people behind Firebug had written to be able use some of Firebug’s functionality in other browsers. They call it Firebug Lite.  This isn’t the full addon for Firefox, so you can’t change CSS on the fly the way you can in Firefox, but it’s still useful for being able to see how the rules you’ve created are getting applied. The following is the script for adding it to your website:

<script type=”text/javascript”
src=”http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js”></script>

Also, for ease of use I wrote a bit of PHP to quickly turn the Firebug Lite script on and off.

<? if ($_GET['firebug']=="1") { ?>
<script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>
<? } ?>

Now all you have to do is view the webpage normally when you don’t want to see the Firebug information, and add the parameter ?firebug=1 to the end of the url if you want to turn on Firebug. (Or, if there are already URL parameters, &firebug=1) I mentioned IE earlier, but if you are having trouble with your website in other browsers, such as Safari or Opera, it works equally well.

Free One Page Website Workshop

By Tim Priebe on July 18, 2009 at 10:39 am in freebies,Technical,Workshops

Laptop in Field - One Page Website WorkshopJoin us for this free workshop! In an hour and a half, learn how to create a website and get it online.

We’ll be providing attendees with several one page website templates to choose from. Then you’ll learn how to fill in your template with actual content.

Once your one page website is ready, we’ll show you how to purchase a domain name and hosting, so your website has a place to live online.

Finally, we’ll look at testing and uploading the final website.

We’d love to see you at this event. If you think you might come, please RSVP through our One Page Website Workshop event page on Facebook.

Display the top level category in WordPress

By Tim Priebe on July 16, 2009 at 12:00 pm in Development,How-To,Technical

Wordpress LogoThe is just a quick WordPress code snippet for those WordPress programmers or code dabblers out there.

Recently we needed a page in WordPress to display the top parent page title rather than the current page’s title as the heading on the page. Here’s the code we used to accomplish that:

<?
$currPost = $post;
while ($currPost->post_parent) {
  $currPost = $currPost->post_parent;
}
$title = get_the_title($currPost);
?>

<h2>[ <?php echo $title; ?> ]</h2>
Older Posts »