Archive for the ‘Web Designing’ Category

Mixing JQuery Lightbox with Innerfade – Your own JQuery Slideshow album

Friday, February 27th, 2009

Did you ever know how simple is it to make a slideshow photo album of your own with JQuery? I tried one by mixing JQuery Lightbox plugin with Innerfade. Some of the best things in life are free and this one’s simple too!

Here goes the code:

Step 1: Download lightbox and innerfade. Place the “jquery.lightbox-0.5.js” and “jquery.innerfade.js” script files into your “js” folder along with other files like “jquery-1.3.1.js”.

Step 2: Copy the CSS stylesheet for lightbox into your ‘css’ folder or in the default theme directory, if you are using WordPress. In WordPress, you shall find the default theme stylesheet, ’style.css’ file at this location.

Step 3: Create the html file for your album. Name it like ‘album.html’. Include the JQuery, lightbox and innerfade script files and any other required stylesheet files as shown below:

<html>
<head>

<link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" />

<script type="text/javascript" src="js/jquery.js"></script>
 <script type="text/javascript" src="js/jquery.innerfade.js"></script>
 <script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>

Step 4: Create your own script file for the album as ‘album.js’. You must include it in your ‘album.html’ file as shown below:

<html>
<head>

<link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" />

<script type="text/javascript" src="js/jquery.js"></script>
 <script type="text/javascript" src="js/jquery.innerfade.js"></script>
 <script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>
<script type="text/javascript" src="js/album.js"></script>

Step 5: Place the following code into your ‘album.js’ file to set up the JQuery calls that need to be invoked on page load.

$(document).ready(
	function(){
		$('#images').innerfade({
		animationtype: 'slide',  //You can change it to 'fade' to
//create a fade animation in your slideshow
		speed: 750,
		timeout: 2000,
		type: 'sequence',
		containerheight: '75px'
	});

	$('#gallery a').lightBox();
});

The above code defines the options for innerfade like the speed of image swap and animation type. It is important to note that there are two div layers with id=”gallery” and “images”. We apply the lightbox effect to the gallery while invoking the innerfade effect on the images. Don’t worry if its confusing. You will understand it better after we see the next step.

Step 6: Add the following stylesheet code into your default ’style.css’ file. Or you can create your custom ‘gallery.css’ file and link it in the header section of your ‘album.html’ file as follows:

<html>
<head>

<link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/gallery.css" media="screen" />
<script type="text/javascript" src="js/jquery.js"></script>
 <script type="text/javascript" src="js/jquery.innerfade.js"></script>
 <script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>
<script type="text/javascript" src="js/album.js"></script>

The following code goes into the ‘gallery.css’ file:

#gallery {	}
#gallery ul { list-style: none; }
#gallery ul li { display: inline; }
#gallery ul img {
	border: 0px;
}
#gallery ul a:hover img {
		color: #fff;
}
#gallery ul a:hover { color: #fff; }

Step 7: Add the following final piece of code to the body of your html file (album.html):

<div id="gallery">
    <ul id="images">
      <li><a href="Winter.jpg" title="Winter">
     <img src="Winter.jpg" width="150" height="150" alt="" /></a>
    </li>
    <li><a href="Sunset.jpg" title="Sunset">
      <img src="Sunset.jpg" width="150" height="150" alt="" /></a>
    </li>
    <li><a href="Water lilies.jpg" title="Water Lilies">
    <img src="Water lilies.jpg" width="150" height="150" alt="" /></a>
    </li>
    </ul>
</div>

The above piece of code creates two div layers. The gallery layer to which the lightbox effect shall be added and the images layer (in fact a ul element) to which the innerfade effect shall be applied to create an impression of a slideshow.

Take care to note where the images are stored. You must refer to the images correctly in the anchor elements.

Thats it! Your own album with slideshow effect is ready! If you click on the slideshow, you can view the images in full size with lightbox effect. Have fun!

Demo: You can try a demo of the slideshow described here.


Adding JQuery to WordPress – For your customized WordPress theme

Thursday, February 26th, 2009

JQuery can be easily added to your WordPress theme. Irrespective of whether you use the default themes from WordPress or if you have customized an unique theme for your website, JQuery will help your website to stand out from the crowd.

I do not prefer to use the integrated WordPress JQuery plugins. In fact, I have not tried them. I always love to add JQuery manually to my WordPress application.

Lets get our hands dirty by straight away jumping into the integration.

Step 1: Create a ‘js’ folder under your WordPress theme directory.

Step 2: Save any of your JQuery stylesheets directly under the theme directory with your other theme stylesheets. One example would be the lightbox stylesheet file.

Step 3: Create a ‘images’ folder under your WordPress theme directory. You may normally already have this directory. Place your JQuery related images under it. For example, the NEXT, PREV and CLOSE buttons of the lightbox plugin can be stored here.

Step 4: create a ‘your_theme_name.js’ file which can be placed under the ‘js’ folder created in step 1.

Sample contents of the js folder:

jquery-1.3.1.js
jquery-lightbox-0.5.js

Step 5: Edit your header.php file in your theme directory to include the ‘your_theme_name.js’ script file and all of your JQuery style sheets (for example the lightbox plugin css file). In this file, you can define the ready() function where JQuery calls can be added.

First, include the script file and stylesheet in your header.php

.....
<link rel="stylesheet" href="/jquery.lightbox-0.5.css" type="text/css" media="screen" />
<script src="<?php bloginfo('stylesheet_directory'); ?><!-- /js/jquery-1.3.1.js" type="text/javascript">
.....

Next, modify the ‘your_theme_name.js’ under the ‘js’ folder to include your JQuery calls

$(document).ready(function() {
.....
/* Sample code to show/hide a layer by clicking on a second layer */
$("#layer1").click(function () {
$("#layer2").show("slide", {}, 1000);
});
.....
}

Thats it! Now, can it be more easier than that?


WordPress Plugins – Five most useful wordpress plugins for your website

Friday, February 20th, 2009

The best thing about wordpress is the ease of installing plugins to it. Plugins provide additional capability and features to your wordpress installation. There are so many plugins available freely that one may get confused as to what may be required immediately after a fresh installation of wordpress. Here, I list the five best plugins which I use on my website and find them to be quite handy.

  1. WordPress Popular Posts
    Did you notice the popular posts section on the left sidebar of my website? No wonder, almost every other blog site has it too. How do we end up to get the popular posts displayed on our sidebar? Simple, just install the wordpress popular posts plugin. It is one of the most useful and simplest of all plugins that I have come across. It is sufficient to paste

    < ?php get_mostpopular(); ? >

    into your pages wherever you may wish to display the popular posts of your blog. Blog posts are rated based on both comments and views which can be controlled from the settings tab of your wordpress dashboard. You can also set the maximum number of entries to be displayed under it.

  2. Recent Posts
    The second most useful plugin without doubt is the recent posts plugin which helps to display the most recent posts of your blog. This is important because when you make a fresh post, there may not be sufficient views or comments to list your latest post under the popular posts section. To handle such scenarios the recent posts plugin is necessary. It is quite simple to use and requires the following

    < ?php php mdv_recent_comments(); ? >

    to be pasted into your pages wherever you may wish to display the list of recent posts in your blog. You can pass arguments to it to restrict the entries under recent posts.

  3. WP-reCAPTCHA
    This plugin helps to prevent spam in your comments by stopping spambots from messing around with your website. This plugin adds a neat box to your comment form with two different words in a distorted manner that the user shall need to fill in before submitting his comment. It requires an unique public and private key for each domain that you may control. The other advantages of using it can be read from http://www.blaenkdenum.com/wp-recaptcha/
  4. Contact Form
    The contact form plugin supports creating multiple contact forms for your website in a simple manner. The contact forms can be created under the settings tab of your wordpress dashboard and included in your ‘Contact’ pages. This is quite a useful plugin that I shall recommend to everyone.
  5. User Photo
    The user photo plugin provides capability to wordpress to associate a photo with every user profile. All registered users can upload pictures and it can be customized easily to be displayed beside posts and comments. The plugin allows users to upload a picture and also creates a thumbnail for it. You can use it’s simple API to display the picture wherever you may wish to on your posts and beside comments.

These are the five plugins that I setup immediately after installing wordpress for my website. Hope you will find this post helpful. What were you looking for immediately after installing wordpress? Don’t tell me you wanted an auto-bot plugin to write your first post! :)



Advertise here!


My Networks
Follow me on twitter!
View Madan Gopal Revoor's profile on LinkedIn