Hint text for the input fields with jQuery

by Tamas Gal on March 3rd, 2010, under jquery | No Comments »

There are lot of site out of the Internet where some help text placed into the input fields. The working mechanism of this fields is easy. When the visitor clicks in the field the text disappear while he clicks somewhere else or navigate anywhere else on the site the text will appear again. This technique is very useful for your visitors to help them which kind of content do you waiting for that input field. It is a part of the user experience what your site can be gives for your visitors.

Needless to say that it is very easy to implement with some line of jQuery code! I would like to share it with this little snippets what I’m using my projects.

Let’s do some jQuery magic! :)


$.fn.hint = function(blurClass) {
              return this.focus(function() {
                if( this.value == this.title ) {
                  $(this).val("").removeClass(blurClass);
                }
              }).blur(function() {
                if( !this.value.length ) {
                  $(this).val(this.title).addClass(blurClass);
                }
              }).blur();
            };

To make it work on thedesired input fields just use it in this way:


$("#input_field_id").hint("help");

You can use any of the jQuery selector technique of course!

The parameter for the hint will be the style for displaying the hint text in the field. In this example I will make the text light grey – you can add it to your .CSS file or definitions:


.help {color:#999;}

OK. But you can ask me where is the hint text itself? It is in the input field title property! Here is one example what you can use your HTML:


<input type="text" value="" id="input_field_id" title="Here is a little help" />

That’s all! If you have any question just ask me.

Optimize page content for SEO

by Tamas Gal on February 25th, 2010, under SEO | No Comments »

On page optimization is one of the very first step of SEO which every webmaster have to do. If you can do proper on-page optimization for your website you can not only rank well in a search engine but also can increase the overall readability of your website for your visitors.

1. Title tag optimization

Title tag is the most important on-page optimization element. A title tag should be short but descriptive enough for your visitors to identify you and your business. Title tag is the first thing that is shown & indexed by the search engines. So naturally it is given a very high importance.

What your title tags should have?

  • Title tags should be short.
  • Put your main keyword in it.
  • One keyword should be repeated three times,  not more then that.
  • It is about your business! So do not use here a welcome message and any other general sentences.

2. Meta Tags

A site’s Meta tags may not be as important as it used to be before, however Meta Description is something you can’t just ignore. A site’s Meta description should contain a brief description of your website focusing on the areas and services that your business is specialized in. This small piece of text can be considered as a selling snippet, if a searcher finds it appealing he is likely to click and go inside your page to find out more information. But if your Meta Description is too generic and isn’t written too well then there is a good chance that your site will simply be ignored.

Things to know about your Meta Description:

  • Meta Description should give a brief introduction about your site.
  • It should contain your main keywords.
  • Should not be too long – one or two sentences are enough based on my experience

3. Headings & HTML Tags

Headings is one of the most important tags in html. HTML contains 6 Headings in it, from H1 to H6.  H1 tag in a page shows the main focus/heading of the site, while it gets lower important with every lower heading tag.

What to do with Heading tags:

  • Your Page must have one and only one H1 tag in it, and the text on which this tag is applied should be your main keyword.
  • Use less important keywords in lower headings.

HTML Tags:

Some other HTML tags contribute alot in your site’s SEO. For example. You should always bold, italize or underline your keywords present in the text of your page.

Text Styles:

  • Bold: You can bold (e.g. [strong]) certain words which are of high importance. Sometimes it’s good to bold your keywords where appropriate. However overdoing this may get you penalized.
  • Italic: You can use the [em] tag to emphasize certain words which will appear in italic.
  • Quote: This is very useful when you are quoting from someone.

4. Keyword Optimization & Synonyms

Your site’s content needs to be optimized in such a way that it can suit both search engines & your readers. Stuffing your site with too many keywords can make your site unreadable. So you will need to have some sort of balance between your keywords & your content.

Important elements of Keyword Optimization:

  • Research: Do a proper research before you decide on your keywords. There are plenty of free tools out there that can help you to do keyword research. Some of my personal favorites are: SEObook Keyword Suggestion tool, Google Adwords Keyword Tool & Overture Keyword Tool.
  • Keyword Density: Try to have a moderate keyword density so that it can help the search engine to determine that your page is indeed related & relevant to the keyword that you are targeting.
  • Synonyms & Related Keywords: I personally like to use synonyms instead of having a high keyword density. This helps to make my content sound natural but still helps in SEO.
  • Long Tail Keywords: It’s often good to target some long tail keywords as they are comparatively easier to rank for. During your keyword research you should be able to gather some good long tail keywords that you can optimize your site for. But you can also come up with your own long tail keywords; for example try adding some common words like – ‘best’, ‘free’, ‘cheap’, ‘top’ etc. along with your actual keyword and you might eventually get some good long tail keywords.

5. Link Optimization

It is important to optimize your internal & external outbound links for search engines as well as to give your visitors a better navigation.

Important elements of Link Optimization:

  • Include the appropriate keyword in the anchor text which gives the outbound link a ‘proper meaning’ and value.
  • A good & clean Internal Link Structure with proper use of anchor text will definitely help. E.g. “New visitor, register here” is a better anchor text compared to “click here”
  • If you are using a CMS, then try using permalinks. This way your keywords/post title will be on the link itself and thus it will valued more by the search engines.

6. Image Optimization

If your site has lot of images, you need to optimize them too as they can’t be read by the search engines. It’s very easy for a human reader to interpret the image into its meaning. However for a Web crawler the whole interpreting process is completely different. Search Engine spiders can only read text but not images. So you need to use some special tags for your images in order to give them some meaning.

Some Important Image Optimization Elements:

  • Alt text : ALT text or Alternate Text is the text to describe your image when your mouse moves over an image on your web page. The text should be meaningful but short. You can use your relevant keywords as ALT text. If your browser can’t display the image for some reason, the alt text is used in place of that particular image.
  • File name : always use meaningful file name for your images, use names like “blue_house_wall.jpg” instead of meaningless “DSC24045.jpg”. Keep image file name same or similar to the ALT text.
  • Image Title : always use the title tag in images which will show the title as tool tip when a user moves his mouse over the image.
  • Image Linking : Whenever you want to link to your image, use the image keywords in your link text. Example: use “View a blue house wall”, instead of “Click here to view” as the anchor text.

50 useful CSS coding techniques

by Tamas Gal on February 19th, 2010, under CSS | No Comments »

“Although CSS is generally considered a simple and straightforward language, sometimes it requires creativity, skill and a bit of experimentation. The good news is that designers and developers worldwide often face similar problems and choose to share their insights and workarounds with the wider community.

This is where we come in. We are always looking to collect such articles for our posts so that we can deliver the most useful and relevant content to our readers. In this post, we present an overview of useful CSS/jQuery coding tips, tricks and techniques for visual effects, layouts and web form design to help you find solutions to the problems you are dealing with or will have to deal with in future…”

Here you can find a lot of interesting and useful CSS techniques. Lot of them are common today, but there are some diamonds :)

Let’s go to read!

http://www.smashingmagazine.com/2010/02/18/50-css-and-javascript-techniques-for-layouts-forms-and-visual-effects/

They are your users!

by Tamas Gal on February 17th, 2010, under General | No Comments »

I found a short but very interesting article on the UXMag and I would like to share it with you. The interesting part is that you and I sitting in a char in front of our laptop and always try to guess the best way to interact with users. The User Experinece (UX) itself meaning that every webdesigner and developer try to make better and better websites and web interfaces. It has to be an ongoing iteration to increase the user’s satisfaction.

But we are sitting in our comfortable chair in front of our laptop and we are guessing what our users like. Sometimes we made a good decision sometimes not. Then we start over our cycle… but why? So, just look at this video and please remember these people when you’re designing your products on the next time.

Improving TableDND usability

by Tamas Gal on November 10th, 2009, under General | 2 Comments »

The TableDnD jQuery plugin allows the user to reorder rows within a table, for example if they represent an ordered list (tasks by priority for example). Individual rows can be marked as non-draggable and/or non-droppable (so other rows can’t be dropped onto them). Rows can have as many cells as necessary and the cells can contain form elements.

This is a great plugin at all, but needs some attention in case of usability. The default behavior of the plugin is passing over the drag-n-drop “ghosting” effect.  (You can see an example here: http://www.gimiti.com/kltan/demo/jTree/)

It is difficult to make the ghosting work with this plugin but I found a very simple solution to do it. I used a small amount of CSS a Javascript code to reach a better usability behavior when a user drag-n-drop a table row.

The main concept was to mimic the ghosting effect in my project.

I used the following CSS lines.


/* This declarations makes a draghandle icon (a small crosshair) visible in the first cell of a table row */

td.dragHandle {padding-left:17px;}
td.showDragHandle {padding-left:17px; background:url(arrow_all_thin.png) no-repeat center center; cursor: move;}

/* The followings will format the entire table row when a user is dragging it */

tr.myDragClass td {background-color: #fff; padding-left:2px;} /* change the background color all of the table cells in the row to white */
tr.myDragClass td a {color: #aaa;} /* change the text color to grey, or just lighter - note: I'm using links in the  TDs */
tr.myDragClass td img, tr.myDragClass td .taskDelete, tr.myDragClass td.napok div {display:none;} /* Do not display any of the images and other informations in the cells. Just show the most important information for dragging and dropping. Other information, icons, etc may confuse the user. */
tr.myDragClass td span, tr.myDragClass td span span {padding:0;} /* Pull the information closer to the drag icon */

After that formatting I played with the plugin itself. I set up it on the following way.


var oldSibling;
 $("#todoList").tableDnD({
 onDragClass: "myDragClass",
 onDragStart: function(table, cell) {

// Saving the row under the dragged one
 oldSibling=$(cell).parents("tr").next();

//Set the CSS class immediately to show the "ghosting" like effect when the user clicks on the row

$(cell).parents("tr").addClass("myDragClass");
 },
 onDrop: function(table, row) {
 var aHtml=$("a", row).html();
 var f=$.getUrlVar('f');
 if(confirm("\nAre you sure to move \""+aHtml+"\" task?")) {
 // Here comes the AJAX call
 $("#cover").show();
 $("#ajaxMessage").show();
 document.getElementById("cover").style.width="100%";
 document.getElementById("cover").style.height=docHeight()+"px";
 $("#bigCal").load("setTask.php?f="+f+"&orig="+row.title+"&"+$.tableDnD.serializeT(), function(){
 $("#cover").hide();
 $("#ajaxMessage").fadeOut(200);
 });
 }
 else {

//If the user Cancel the moving we have to take back the row to the original place
 $(row).insertBefore(oldSibling);
 }
 },
 dragHandle: "dragHandle"
 });

As you can see I made the drag-n-drop cancel functionality also. :)

TODO: Handle the oldSibling if the moved row was the last row in the table.

Do you have any thoughts or question?

How to make different sidebars for posts, pages

by Tamas Gal on September 16th, 2009, under Wordpress hacking | No Comments »

Who has ever made a complicated Wordpress setup bump to the problem: how can I make different sidebars to my pages in my theme? I bumped it of course and I found a very simple solution for it. It is very flexible and needs only a basic level of PHP programming so I think anybody can do this with his/her WP theme.

OK, let see the problem and then the solution.

The problem

Normally there is only one sidebar.php in Wordpress which you can found in the wp-content/themes/your-theme-name directory. This sidebar.php can be called with the get_sidebar() function. In the default WP setup you can find this function calling in the single.php (displaying a single post), in the page.php (displaying a page) and in the index.php (listing posts). You have only one sidebar.php to modify -if you like- in your WP setup. There are many reasons to use more than one. For example: you have a different front page than your post displaying page, or you would like to differentiate your posts and pages, or you would like to build up a whole site based on the WP very good content management system (CMS).

The solution

I do not like to mixed up the original WP’s operational mechanism thought that I like to upgrade my WP with new versions. Keep this fundamental thing in my mind I make a small modification only in my page.php. I did not bother the single.php and the index.php because these files was good for me with the original sidebar.php.

First of all I made two copy of the sidebar.php. I renamed the first to sidebar1.php and the second to sidebar2.php (I do not want to use my brain capacity to guess a cool name :) )

Then I modified the page.php a bit. Here is the code and than I will give you a explanation.

Comment out the get_siderbar() row in your page.php file and insert this code after it.


switch(true) {
 case is_page('contact'): //Contact
 include(TEMPLATEPATH."/sidebar2.php");
 break;
 case is_page('projects'):
 include(TEMPLATEPATH."/sidebar1.php");
 break;
 case is_page('services'):
 include(TEMPLATEPATH."/sidebar1.php");
 break;
 case is_page('about'):
 include(TEMPLATEPATH."/sidebar1.php");
 break;
 case is_page('privacy-policy'):
 include(TEMPLATEPATH."/sidebar1.php");
 break;
 case is_page('sitemap'):
 include(TEMPLATEPATH."/sidebar1.php");
 break;
 default: get_sidebar();
 break;
}

I do not like to use many ugly if statement so I use a switch. In the switch statement I used the value true to jump in it. Then I used the is_page() WP function to check the pages where I want to use my different sidebars. You can make a very simple to understand code with the is_page() because in the parameter you have to use your page’s or post’s slug. Slug is your shorthand name of your post which makes your site URLs SEO friendly.

The default value of the switch is the get_sidebar() which will call our original sidebar.php.

I think it is very easy and nice. Do it with your themes if you need!

Post me a comment if you use my mod I’m very interested it was easy to implement to others or not.

Separating posts, pages and homepage in Wordpress – clean and simple way

by Tamas Gal on September 12th, 2009, under Wordpress hacking | No Comments »

I played a bit with separating posts, pages and the home page in Wordpress today. I tried to find a solution with Google, but there are some tutorials only about the posts and pages separation. I needed something more! And I found the solution what I would like to share with you.

Home page, pages, posts all in one CMS

  • I have a let’s say “independent” home page (the welcome page)
  • I have static pages with static navigation
  • and I would like to write posts so I need:
    • posts listing page
    • single post displaying page

To see the result just look at Eldanor.hu itself. The site have a custom welcome page. There are pages with different sidebars and there are blog posts.

Sounds a bit complicated but it is very easy to implement the whole thing in Wordpress. The more good news is that we learned a simple but magical thing about Wordpress.

Let’s get started!

Make a homepage template

You can create a HTML or PHP file for your home page depends on your needs. To make it simple call your file homepage.php. Place this file in your currently used template directory (for eg. ./wp-content/themes/templatename).

Add the followings in the beginning of your homepage.php

/*
Template Name: HomePage
*/

You can select this template for your pages!

Do not forget that this “template” contains any PHP code, any HTML or JavaScript – so you are able to create a homepage as you like.

Create your Home page

After you created your HomePage template you can create your Home page. Go to your Wordpress admin and there on the left hand side select Pages, and then selec “Add New”. Write Home in the title field and leave everything blank. You have to select a template for your new page. Select the “HomePage” template from the Template dropdown in the Attributes box. (Do you remember? We have created our HomePage template in the first step.) Now you can hit the Publish button!

Create your post listing page

Go to Pages and select “Add New”.  Write Blog in the page title. Leave every other field blank and hit the Publish button.

Do some magic

Now we have two new pages. The first is called Home and the second is called Blog. We joined the Home page and our homepage.php template together.

We have to do some easy steps in the Wordpress Admin. Go to Settings and select “Reading”.

How to set your front page in Wordpress

How to set your front page in Wordpress

You have to select the “A static page” option. Then select your Front page from the dropdown menu – our front page name is Home! Select the Posts page. Our front page name is Blog. Hit the Save changes button and leave Wordpress to do the magic!

Now you can see your homepage.php as your homepage (welcome page) and if you like to see your blog posts you have to navigate to blog (for. eg. http://www.yourdomain.com/blog/) and even more you can create pages. All of these are separated and easily managed now from the WP admin!

That’s all!

At the First Time

by Tamas Gal on September 10th, 2009, under General | No Comments »

We have started our new site finally! The projects page is waiting for upload all of our past and present projects.  We are very busy in these days about the lot of work but we try to upload all of the information what we have decided.

There are four goals of the Blog section:

  1. to inform our customers about the latest news, changes, projects of our company
  2. to inform our prospect clients our abilities
  3. to make a good collection about articles, tutorials which are inspiring our daily work
  4. of course we wanted to make our own publications to help others making good looking/working websites

We wanted to publish blog posts weekly but if we see an interest we will change this frequency! :)

mjqegd345s