Android background processing – AsyncTask

Developing on Android? Need to call the some services or sync with cloud servers or may be you need to do some time consuming task you need to do background processing

there are three ways to do that

AsyncTask

Service

Thread

Today we will see how AsyncTask works, AsyncTask is a wrapper around Threads. It allows to process something in background and post the results and progress on UI Thread in relatively very easy manner.

For implementing AsyncTask you need to extend

android.os.AsyncTask<Params, Progress, Result>

the three Type parameters that you can specify are

Params –  the type of the parameters sent to the task upon execution.

Progress –  the type of the progress units published during the background computation.

Result –  the type of the result of the background computation.

In AsyncTask you must implement the doInBackground (Params… params) method which needs to return the Result type parameter you have defined. You need to do or call the required background processing in this method. Other then that you can implement this following methods.

onPreExecute() – Runs on the UI thread before doInBackground. You can do any UI related update in this i. e. showing progressbar.

onProgressUpdate (Progress… values) – It runs on UI Thread when you call publishProgress (Progress… values) i. e. you can update your preogressbar for the progress being done in this method or may be adding fields to your layout.

OnCancelled() – is called after doInBackground (Params… params) when AsyncTask is cancelled by calling cancel(boolean) we should keep checking weather the task is cancelled using isCancelled() method inside doInBackground (Params… params).

onPostExecute (Result result) – It is executed after doInBackground the parameter Result is needed to be Type of Result you have set in your class header. The reault is what you have returned in doInBackground. onPostExecute runs on UI thread so you can reflect completion of your background processing according to the result you received. i.e. hiding the progressbar and showing the final outcome of processing.

Let us see an example on AsyncTask.

I assume you have already setup android and eclipse with adt and know how to create basic project. If not have a look here

First of all we will declare the AsycTask we want to use with following statement

AsyncTask<String, String, Void> myTask;

To make the UI we will create the following structure within main.xml file

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/Buttons"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:onClick="startTask"
        android:orientation="horizontal"
        android:text="@string/startTaskString" >

    <Button
        android:id="@+id/startTaskButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="startTask"
        android:text="@string/startTaskString" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="cancelTask"
        android:text="@string/cancelTaskString" />

    <ProgressBar
        android:id="@+id/progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="invisible" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/ListParent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/Buttons"
        android:orientation="vertical" />

</RelativeLayout>

For representing this UI component in out Activity we will declare the following Fields

RelativeLayout mainLayout;

ProgressBar mProgressBar;

LinearLayout mListParent;

and here goes onCreate method of activity with helper method to show hide the ProgressBar

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mProgressBar = (ProgressBar) findViewById(R.id.progress);
    mListParent = (LinearLayout) findViewById(R.id.ListParent);
}

public void showProgressBar(boolean show) {
    if (show) {
        mProgressBar.setVisibility(View.VISIBLE);
    } else {
    mProgressBar.setVisibility(View.INVISIBLE);
    }

}

and to add actions on the two buttons we hace added the tags

android:onClick="startTask"

and

android:onClick="cancelTask"

So when this buttons are clicked the methods startTask and cancelTask will be called . We need to create this methods in our activity.

startTask will create task and run it while cancelTask will cancel the task if it is running.

 

public void startTask(View v) {

    myTask = new AsyncTask() {
        String[] splittedString;

        @Override
        protected Void doInBackground(String... params) {

            splittedString = params[0].split(" ");
            for (String currentString : splittedString) {
                if(isCancelled()){
                    splittedString = null;
                    currentString = null;
                    break;
                }else{
                    publishProgress(currentString);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    e.printStackTrace();
                    }
                }
            }
            return null;
        }

        protected void onCancelled() {

            showProgressBar(false);
        }

        @Override
        protected void onPostExecute(Void result) {

            super.onPostExecute(result);
            showProgressBar(false);
        }

        @Override
        protected void onPreExecute() {

            super.onPreExecute();
            showProgressBar(true);
        };

        @Override
        protected void onProgressUpdate(String... values) {

            super.onProgressUpdate(values);
            TextView mTextView = new TextView(AsyncTaskDemoActivity.this);
            mTextView.setText(values[0]);
            mListParent.addView(mTextView);
        }

    };

    myTask.execute(new String[] { "This is asyncTask Demo." });

}

public void cancelTask(View v) {

    myTask.cancel(true);

}

 

Here inside startTask we create new instance of AsyncTask and assign its handle to myTask while inside cancelTask we just call cancel() method of myTask.

You can download the source code of this tutorial from here and run it for your self.

When you click startTask button it will create new AsyncTask and execute it with parameter String “This is asyncTask Demo.” and split the string in background and display at particular interval demonstrating updating UI with process update. You may do any other background processing here and reflect it to UI through onProgressUpdate method.

Thats it for AsyncTask. We will discuss Background processing with Services in Android in Upcoming Posts.

WordPress How to set SESSION Custom Variable While Login

Hello friends,

Sometimes we need to set custom session variable for using in our custom code or any other web application which also running parallely with our wordpress installation. Also some time there is need to set and destroy our session variable for our custom web application when wordpress user login or logout.

So first of all we need to enable session in wordpress. I have tested this code in wordpress 3.X. First we need to start the session every time wordpress initialize. To initialize session in wordpress we can use below code.

add_action('init', 'session_manager'); 
function session_manager() {
	if (!session_id()) {
		session_start();
	}
}

This will start the session every time wordpress loads. In this function you can write any other session variable that you need to set default. Then we also need to destroy the session when wordpress user logout. To destroy the session and unset any variable we can use below code:

add_action('wp_logout', 'session_logout');
function session_logout() {
	session_destroy();
}

In this function you can write any other session variable that you want to unset.

Now, How can we set user data into the session variable? Answer is very simple see the below code:

add_filter('authenticate', 'check_login', 10, 3);
function check_login($user, $username, $password) {
     $user = get_user_by('login', $username);
     $_SESSION['userdata']=$user; return $user;
}

Here we add authentication filter of wordpress to set the session. Also we can use this authenticate filter to restrict certain user from login into the wordpress. This function will set the session and later we can use it any where in the wordpress. Also you can set other system session variable so that when any user logs in wordpress he also get logs in other Custom system but condition is both wordpress installation and custom system need to be on same server.

Please post your comment here if this information helps you. I will keep posting more as I come to know more things.

Thank you 🙂

 

 

 

6 Essential Business Tips To Grow Your Side Business

I’ve been creating websites for 10 years. I started my career knowing absolutely nothing about web design or development.

I went to school for graphic design and figured web design can’t be much different (though it is).

I’m your typical working class person. I traveled the traditional route of going to college then getting a job. Everyone and I mean EVERYONE would always tell me, “you need to get a good job”, “you need a nice paying 9 – 5″, “work on your resume so someone will hire you”. The person inside me always had to do the right safe thing and I always did.

You may have read books are heard stories of people that will tell you how to be successful, how to be a millionaire, business secrets of someone that’s already rich, and all the rest. Once you read these you realize that this is all coming from a perspective of someone whose already there or has been there for some time.

I bet you’ve heard this before too “You don’t get anywhere without taking risks.” I just want you to know that I hate that saying. I’m married with a newborn baby. Am I really going to “risk” the well being of my family for sake of my dream?

If you’re like me, you can’t just quit your day job and do what you want. However, you still want to do something. Well, I’ve been doing something since I started my career in web design and I’m slowly starting to see the efforts pay off.

I’m going to share with you what I’ve learned in my career so far and how I continue to move forward. I’ve never done this before as I always felt that selfish attitude like “Oh, look what I found, now I’ll keep it for me.” But as I grow, I realize that that is something I just can’t do. I’ll get more into that in another topic, but let’s start off with my opinions on the basics.

1. The Best Time To Start A Business

I think the best time to start a business is once you graduate, whether it’s high school or college. Like most people, when you graduate high school or college you live at home.

When my kid is older he’s going to read this and I’m going to kick myself for writing it, but when you live at home MILK YOUR PARENTS FOR EVERYTHING IT’S WORTH! I’m serious! You really don’t have any responsibilities yet. You may pay a bill here or there, but you’re not paying rent or mortgage. When you don’t pay rent or mortgage, or grocery shop, or (add any one of the many expenses home owners/renters pay), you can live like a king with such a tiny bit of money!

The sad thing for me as an adult, is I didn’t realize this until I was already moved out in an apartment with my wife. But fret not fellow readers, that doesn’t mean it’s too late to start a business. That only means you have to start getting creative and seeing what kind of business you can manage. As a full time web designers/developer, this decision was clear.

The business really doesn’t have any overhead. These were my total expenses

  • Buy a computer for working (if you don’t have one) – $2k (Yeah I splurged a little but you know what, you need a good computer. Plus this was like 6 years ago and it’s still running nice!)
  • Buy a domain – $10 a year, if that.
  • Get a hosting account – $10 bucks a month.

That’s it.

Now you can start at any time, at any point, and your monthly overhead is nothing.

2. Start somewhere

You may not know where you want to be in 5 years, but the key is to start somewhere, anywhere. It doesn’t matter, just do something, even if it’s writing ideas down. I have SO many ideas in my head and topics that my problem is I don’t know where to start. Pick one and roll with it!

If you get caught up with multiple ideas, figure out which one will be the most beneficial to you and start there. Even though you think all of your ideas are million dollar ideas, the reality is, you can’t do everything.

Find what’s practical and push it full throttle.

3. Network your ass off

This is definitely one of, if not the, most important rule of all. What you do now will pay off years down the line. People you meet, events that you go to – these all play a huge factor in getting people to know you. Carry business cards or some type of trinket that you can leave with everyone you meet, and I mean EVERYONE!

When you go to the doctor, leave some cards. If you meet a new person from a friend, leave them a card. Leave cards everywhere you go and with everyone you meet. Make sure they know exactly what you do.

I’ve received calls and emails from people that I barely spoke to saying they had one of my cards and they needs a website. Most of the time this turns into new jobs for me, which means more money! Network and don’t stop networking.

4. Read and Learn as much as you can, as often as you can

Diversify yourself and at the same time keep your niche. What I mean by that is learn a little about everything and apply it to what you already know. Experiment with everything you learn and always remember…You Will Fail –It’s perfectly OK to fail. As a matter of fact, if you never fail, you’ll never learn anything.

Read how experienced professionals do things and see how you can apply it. Learn new techniques to solve common tasks. As long as you keep on learning, you’ll always have an opinion and can figure out how to tweak strategies, techniques, amongst many other things to your benefit.

The best part is you’ll always be able to regurgitate certain things to YOUR audience in your own words… great for blogging!

5. Your business should reflect who you are

You’ll hear stories of how certain people manage their time, and howtheygot money, etc. What you need to do is focus on you. Take everythingtheydid and see how it relates to what you want to do. A lot of times, things don’t work out and certain requirements/capabilities are out of your means. That’s normal.

Your business has to be YOUR success, not someone else’s. Build it how you want it. If something isn’t working, find ways to change it, but you have to remain happy. After all, this is something that you want to do and hopefully have a passion for.

6. Don’t be selfish

Probably the hardest thing to do in any business is share what you’re doing. We hold on to words like “proprietary” or “non-disclosure”. This is my idea and my idea is going to make a million dollars and I can’t share it with anyone because then they will do it.

You’re not going to like me for this but…WHO CARES?!

If you don’t make a move on YOUR idea and someone else does it before you because you shared it, guess what, that’s life. Yes, it may suck but in the time I’ve been creating websites, I’ve realized something.

No one cares about your idea. People are wrapped up with there own ideas and day to day life that they probably don’t even have time to work on your idea. Even still, when you release your idea to the public, guess what, people are probably going to steal it. Sorry to be so blunt but here’s an example:

  • Pepsi – Coke
  • Seagrams Ginger Ale – Schweppes Ginger Ale
  • Windows – Mac
  • Ford – Nissan, Toyota, Hyndai

The list can go on. There can be more than one of something, and most of the time there usually is.

The way to deal with it is simple. It’s your idea, so you though of it, therefore, no one will be able to do it like you. Plus, since itisyouridea, you can always change it and you’ll ALWAYS be one step ahead of the person who took it from you.

I understand that this is hard to do because I’m definitely guilty of it myself. By writing this article, I’m basically pouring out my 10 years of experience in business (side business) and letting you in my head. In the future, I’ll also be sharing my “million dollar” ideas and I hope when someone takes them, they give me some cred =).

So there you have it! Those are my 6 essential business tips to grow your side business. If your a full time working person and need some cash on the side, these tips will definitely keep it flowing. If you decide that you want to take your side business and go full time, then these business tips will definitely help your side business grow into a full on business.

About the author:

My name is Jonathan and I’ve been creating websites for about 10 years now.

I love to use the Genesis Framework and have been working in depth with WordPress for the last couple of years. I’m an expert in front-end HTML and CSS as well as a successful web designer and graduate of Ben’s Pro Web Design Course.

You can visit my blog any time at SureFireWebServices.com to find practical uses of html, wordpress, css, and jquery as well as some of my insight to the web world.

 

Note: I have taken this Post from Here http://www.webdesignfromscratch.com/business/6-essential-business-tips-to-grow-your-side-business/ ,

Thanks to post such a lovely post. I am posting it here again for my and my friends reference.

Thank you

What is Content Management?

Now a days, Many CMSs (Content Management Systems) are available. Many of them are in PHP, .Net, Java and other computer web languages. Every time we came accross the CMS in day life. So the question is what is content management exactly? So I write an article on it. Hope this will Help you…!

Understanding Content

Before We go into content management, We should take a moment to better understand
the concept of content itself. Only in this way we can more fully understand content management, the impact it has had in modern-day e-business, and the effectiveness, usefulness, and vital role of CMSs.

We define content in an organization as any organizational informational asset that exists in an electronic medium. Although it can be argued that any physical information resource can be classified as content, in the context of this article and content management systems we will not consider any source as content until it exists in an electronic form. Some typical examples of content include e-books, manuals, publications, web pages, video files, music, instructional material, promotional material, help text…the list goes on and on. You can classify anything as content for an organization if it fits into all of the following sections.

Content Has a Classification Type

Typically the classification type is organizational; in other words, content can be categorized by an organizational unit such as marketing content, legal content, general content, privacy content, and so forth. A company that performs only legal services may use contracts, wills, deeds of trust, billing invoices, summons, and other legal type content, while a medical publishing company may depend upon drug data sheets, patient handouts, medical books, and drug news as content

Content Has a File Type/MIME Type

Any piece of content has an associated file type, that is, the file extension that is tied to a particular program or standard. On the Windows platforms, file extensions tell the operating system the program or application to launch to service the specific file type. For example, an image file will generally have an extension such as .gif, .jpeg, .jpg, .bmp, .png, or .tif. In a CMS, file types are important to drive storage placement and delivery requirements, as well as to determine how certain files will be viewed. For example, in CMSs, the file type may control whether certain files are displayed in an iframe, a separate window, or the current window.

Content Has Metadata

Content has data attributes that describe it. These data attributes are described collectively as metadata. Metadata is used for many functions within a CMS:

Indexing data for search-related capabilities: You can intelligently add keywords to each content type via a defined taxonomy. A taxonomy is an intelligent mapping of taxons (the highest-level grouping) and taxa (subgroups under each taxon) that are unambiguous and, when taken together, consider all the possible values. For example, have you ever played the guessing game 20 Questions? This game usually starts with someone thinking of something that you then have to guess based on the responses of the 20 questions you get to ask. Usually you start by asking something similar to “Is it an animal, vegetable, or mineral?” If the other person playing with you answers your question by saying “Animal,” then you may ask “Is it a dog, cat, or human?” You will then continue until you guess the subject or you run out of questions. Each of those high-level categories of Animal, Vegetable, or Mineral would be a taxon. The taxa would then stem from the higher-level taxon; for example, the taxa for the Animal taxon might be Dog, Cat, and Bird.

Clustering on metadata and exposing that clustering to search: For example, by clustering metadata, you can list all books or all documents from the marketing department or list all the content about a certain topic. With clustering metadata, you can capture important information such as the author name or publish date. When exposed to a search engine, you then provide the ability to list all books published by a certain author or, for example, all books published from 1995 to 2001. You could also capture the subject for specific topicbased searching. By clustering with metadata, you can accomplish advanced searches such as retrieving all the books published by a certain author, of a certain subject, and published from 1995 to 2001. By having clustering data available, you can group search results and create dynamic drill-down capabilities by dynamically rebuilding the search query.

Automating system-created content using an intelligent method: You can create new and complete content dynamically, where pieces of content are combined or aggregated into an entirely new piece of content based on system requirements or at run time. If content authoring is performed where content is created at the smallest possible level, then this is possible but still difficult to accomplish. Synthesizing content is especially useful for content such as marketing collateral and presentations that should be shared across an organization or several diverse sales teams.

Determining when data should be archived and when data should be removed: These topics are often overlooked in a CMS application. By setting metadata attributes and associating those attributes with content, you can manage the demotion or deletion of content. Additionally, if your corporation has retention standards, you can programmatically control when content is archived and even where the archived content is stored.
Determining when content is promoted or published: By associating metadata with your content, you can program that content’s promotion date and time. A business content review process will control when the content has reached an acceptable publishing state, but why not also control when that content is made live?

Content Requires Storage

Simply put, content takes up space, which is typically database space or space on a file system. Some examples of storage space used to store content include network-attached storage devices such as those provided by EMC, relational databases such as Oracle or SQL Server, and file systems such as the Unix file system or NTFS. No matter what the content or the content’s type, you must have adequate space in which to store it. All content has a certain number of bits and bytes that compose it. This collection of bits and bytes takes up disk space and must be accounted for in a CMS

Content Has a Purpose Not Related to the CMS

Configuration files, templates, or any other files that are used by the CMS should not be considered actual content. Basically, any file that does not provide value to a consumer of the content is not considered content. People who use content are also known as content consumers.

Content Management Defination

Content management is the organizing, directing, controlling, manipulating, promoting, and
demoting of content and/or digital informational assets within an organization. Promoting
content means deploying content from the authoring environment to the content delivery
environment, which is usually a web server. Demoting content means removing or rolling
back content from the content delivery environment to the content authoring environment.

A CMS manages those various pieces of content described earlier. This is extremely important for organizations because as a business grows, so do the complexities of its content. Businesses have hundreds, thousands, and sometimes millions of pages of content, and with the overwhelming flood of this content, they need help! A CMS is much more than an off-theshelf piece of software that a company purchases and configures for its specific needs. To understand content management, you not only have to have a view of the proverbial forest but also need to know where each tree belongs. Implemented properly, content management and a CMS can do the following:

  • Improve delivery time from content creation to content promotion
  • Improve content quality
  • Reduce the cost of managing an organization’s global or departmental content
  • Reduce redundancies in content and reduce human error
  • Eliminate orphaned files and broken links
  • Automate content notifications and the review process
  • Enforce legal and branding standards
  • Improve content visibility and accountability throughout the delivery chain

Implemented poorly, a CMS system can be a virtual money pit, where no efficiencies are gained and many hours are wasted on a project that may provide little to no value to end users or consumers. You must understand two important facts regarding a CMS:

  1. A CMS will not improve your business process. You will have to expend some analysis cycles and rethink existing processes and procedures to enhance your business flow. Only by improving your existing process will you realize the true benefit of content management.
  2. A CMS is not free. Skipping the cost of the solution itself, you will be burning hours to implement a system. Once everyone starts to use the system and find out what the system can do, they will want more. This will also lead to additional implementations and maintenance. This is a topic we cannot reinforce strongly enough: setting up a CMS is more expensive than just building an initial website. You must be willing to accept the initial cost of building and deploying a CMS before you experience a return on investment. But you will have to trust that all of the hard work, project hours, and budget allotments will pay off in the end.

Please comment below if you have any queries. We always here to help you.

WordPress Insert Post from Front End

Hi, In this article I will show one example plugin for making post entry from wordpress front end.

Screenshot:

Below is the sample code for the plugin

<?php
/*
Plugin Name: Insert Post Fontend Demo Plugin
Plugin URI: http://thedigilife.com
Description: Example Insert Post Plugin and Approval from admin
Author: The Digi Life
Version: 1.0
Author URI: http://thedigilife.com
*/
add_shortcode('insertpost','display_insert_form');
function display_insert_form($atts)
{
	if ( !empty($_POST) && !wp_verify_nonce($_POST['insert'],'insert_form') )
	{
		echo 'Sorry, Problem in submitting form';
	}
	else
	{
		// process form data
		$post_data = array(
		'post_title' => $_POST['title'],
		'post_content' => $_POST['description'],
		'post_status' => 'pending',
		'post_author' => 1,
		'post_category' => null
		);
		if($post_id = wp_insert_post($post_data)) echo "Data Succcessfully added";
	}
	?>
	<form action="" method="post" name="insert_form">
		<table>
			<tr>
				<td><label>Title</label></td>
				<td><input type="text" name="title" id="title"></td>
			</tr>
			<tr>
				<td><label>Description</label></td>
				<td><textarea rows="7" cols="10" name="description" id="description"></textarea></td>
			</tr>
			<tr>
				<td colspan="2"><input type="submit" id="button"></td>
			</tr>
			<?php wp_nonce_field('insert_form','insert'); ?>
		</table>
	</form>
	<?php
}

We can insert post in wordpress using wp_insert_post which is explained Here

In this sample I have created one sample shortcode for displaying plugin on front and in short code function I have added form to display and before that if post is submitted we will insert the post into database.

 Download | Source Code

 

WordPress Admin listing Table and Paging

Almost svery wordpress plugin developer needs to make Admin side listing for any custom table. This table generally store information that is gather from website and/or end users. Listing of table help to view the data in list format. It also allow admin to add, edit and Delete the data. It also allow bulk action for delete.

During my plugin development, I always wonder that how to make admin side listing for custom table which looks same as post and page listing. Also how can I make pagination for the table. I have searched for pagination and found many class to use that you can also found in my previous post. But I want to make it looks like as below:

 

 

After Searching for this I come to know that wordpress also providing the class for listing and paging for custom table. Class Name is Wp_List_Table. Wp_List_Table class is used to create admin screens for the wordpress. We need to extends this class and overload its method to use it.

Now the question is how to use this class and create admin side listing for our created custom table.

WordPress is providing one very good example plugin to see how we can create admin side listing for the custom table. You can find the example plugin Here

This example display code using Array of data. Instead of data we can use any database table. For creating your own table listing copy paste data into your file and follow below steps

Step 1: Create a new file under your plugin directory

Step 2: Include WP_List_Table class file into your file as follow:

if(!class_exists('WP_List_Table')){
 require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}

Step 3: Create class for your custom table and extends it to WP_List_Table.

For this you can copy whole class from example plugin and paste it in your plugin file and rename the class name from TT_Example_List_Table to something else which is preferable for your plugin.

Step 4: If you are using database table for fetching data which will always a case in real life,  then delete the example data array.

We will fetch the data from database when it will be needed. Remove the below code:

var $example_data = array(
	 array(
	 'ID' => 1,
	 'title' => '300',
	 'rating' => 'R',
	 'director' => 'Zach Snyder'
	 ),
	 array(
	 'ID' => 2,
	 'title' => 'Eyes Wide Shut',
	 'rating' => 'R',
	 'director' => 'Stanley Kubrick'
	 ),
	 array(
	 'ID' => 3,
	 'title' => 'Moulin Rouge!',
	 'rating' => 'PG-13',
	 'director' => 'Baz Luhrman'
	 ),
	 array(
	 'ID' => 4,
	 'title' => 'Snow White',
	 'rating' => 'G',
	 'director' => 'Walt Disney'
	 ),
	 array(
	 'ID' => 5,
	 'title' => 'Super 8',
	 'rating' => 'PG-13',
	 'director' => 'JJ Abrams'
	 ),
	 array(
	 'ID' => 6,
	 'title' => 'The Fountain',
	 'rating' => 'PG-13',
	 'director' => 'Darren Aronofsky'
	 ),
	 array(
	 'ID' => 7,
	 'title' => 'Watchmen',
	 'rating' => 'R',
	 'director' => 'Zach Snyder'
	 )
	 );

Step 5: Setting up the naming and some configs for table listing.

function __construct(){
 global $status, $page;

 //Set parent defaults
 parent::__construct( array(
 'singular' => 'movie', //singular name of the listed records
 'plural' => 'movies', //plural name of the listed records
 'ajax' => false //does this table support ajax?
 ) );

 }

Step 6: Set Default common value display for the every column using.

function column_default($item, $column_name){
 switch($column_name){
 case 'rating':
 case 'director':
 return $item[$column_name];
 default:
 return print_r($item,true); //Show the whole array for troubleshooting purposes
 }
 }

This method is called when the parent class can’t find a method  specifically build for a given column. Generally, it’s recommended to include one method for each column you want to render, keeping your package class neat and organized. For example, if the class needs to process a column named ‘title’, it would first see if a method named $this->column_title() exists – if it does, that method will be used. If it doesn’t, this one will be used. Generally, you should try to use custom column methods as much as  possible.

Step 7: If you have any column column which need to be display diffidently from other in the view. We can create this by below syntax

function column_<field name>($item){
//Some Code
return "formated text";
}

In example below is given

function column_title($item){

 //Build row actions
 $actions = array(
 'edit' => sprintf('<a href="?page=%s&action=%s&movie=%s">Edit</a>',$_REQUEST['page'],'edit',$item['ID']),
 'delete' => sprintf('<a href="?page=%s&action=%s&movie=%s">Delete</a>',$_REQUEST['page'],'delete',$item['ID']),
 );

 //Return the title contents
 return sprintf('%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
 /*$1%s*/ $item['title'],
 /*$2%s*/ $item['ID'],
 /*$3%s*/ $this->row_actions($actions)
 );
 }

step 8: Display Check boxes for the bulk action.

&nbsp;function column_cb($item){
  return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
/*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie")
/*$2%s*/ $item['ID'] //The value of the checkbox should be the record's id
  );
}

step 9: get all column. here we specify which column to get for display.

This method dictates the table’s columns and titles. This should return an array where the key is the column slug (and class) and the value  is the column’s title text. If you need a checkbox for bulk actions, refer to the $columns array below.

function get_columns(){
 $columns = array(
 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
 'title' => 'Title',
 'rating' => 'Rating',
 'director' => 'Director'
 );
 return $columns;
 }

Step 10: Decide which column to make sortable. This Method is optional.

If you want one or more columns to be sortable (ASC/DESC toggle), you will need to register it here. This should return an array where the key is the column that needs to be sortable, and the value is db column to sort by. Often, the key and value will be the same, but this is not always the case (as the value is a column name from the database, not the list table).
This method merely defines which columns should be sortable and makes them clickable – it does not handle the actual sorting. You still need to detect the ORDERBY and ORDER query string variables within prepare_items() and sort your data accordingly (usually by modifying your query).

function get_sortable_columns() {
 $sortable_columns = array(
 'title' => array('title',true), //true means its already sorted
 'rating' => array('rating',false),
 'director' => array('director',false)
 );
 return $sortable_columns;
 }

Step 11: Set up bulk action for selected check boxes. This method is optional

If you need to include bulk actions in your list table, this is the place to define them. Bulk actions are an associative array in the format ‘slug’=>’Visible Title’

If this method returns an empty value, no bulk action will be rendered. If you specify any bulk actions, the bulk actions box will be rendered with the table automatically on display().

Also note that list tables are not automatically wrapped in <form> elements, so you will need to create those manually in order for bulk actions to function.

function get_bulk_actions() {
 $actions = array(
 'delete' => 'Delete'
 );
 return $actions;
 }

Now we also need to set up what to do when any one of the bulk action has been called. This can done using below method. This method is optional.

function process_bulk_action() {
 //Detect when a bulk action is being triggered...
 if( 'delete'===$this->current_action() ) {
 wp_die('Items deleted (or they would be if we had items to delete)!');
 }
 }

step 12: This is most important step for the listing the table and fetching the database values.

Here find and delete the code

$data = $this->example_data;

Below that there is function

function usort_reorder($a,$b){
 $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'title'; //If no sort, default to title
 $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc'; //If no order, default to asc
 $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
 return ($order==='asc') ? $result : -$result; //Send final sort direction to usort
 }
 usort($data, 'usort_reorder');

Also delete this code this code is now no more needed as we are sorting through database query. Add The below Code here

global $wpdb;
 $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'sent_time'; //If no sort, default to title
 $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc'; //If no order, default to asc
 $query='select * from <Table_name> order by '. $orderby . ' ' .$order;
 $data = $wpdb->get_results($query, 'ARRAY_A');

Here first we have called global variable which is available in wordpress for the database operation. ‘$wpdb’ . Then set order by and order values and get the data.

Every things else remain as it is in this function no need to change.

step 13: Now we need to create function which will be called when page is going to display. We just need to create object of our newly created class.

//Create an instance of our package class...
 $testListTable = new TT_Example_List_Table();
 //Fetch, prepare, sort, and filter our data...
 $testListTable->prepare_items();

And Display the data

<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
 <form id="movies-filter" method="get">
 <!-- For plugins, we also need to ensure that the form posts back to our current page -->
 <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
 <!-- Now we can render the completed list table -->
 <?php $testListTable->display() ?>
 </form>

Conclusion

This will create both listing and pagination for custom table in wordpress. I think this is really easy to use it rather creating table by self and searching for the pagination class and adding them to the code.

This helps developers to create very neat and clean code. Also, This code is fully compatible with wordpress.

Please comment your queries, Suggestion, Like or Dislike post here.

Enjoy..!!!

Note: This example which I have used which is already available in wordpress listing table plugin. I have explained using database connection which was missing in the plugin. Hope this will helps every wordpress developers.

Thank you….

Add Pagination Into WordPress Admin For Plugin

Often in many application, such as in WordPress Plugin, we will need to deal with list of records. As the records grow, more records will need to be displayed. There is a catch though, if you retrieve all the records at one go because it will slow the system down.

In order to have a better user experience for record listing, paging comes into play. It’ll not only help to organize the records by limiting the number of records you want to show per page, it also cuts the down the time of retrieving records. Therefore, pagination plays a very important part in providing a great user experience when interacting with the data.

Imaging if you have a list of 1000 or more records that you want to display. Without pagination, listing all the records will definitely take quite awhile and also increase the load for the database server when executing the query. This is not very efficient, even though retrieving records from database can be cheap.

Now let’s say we want to add in pagination into the 1000 records, by specifying the limit, it will only shows the exact amount of records you want to view. This is a huge benefit for the database server load, because we are not retrieving all the records at once.

Below examples are 2 different type of pagination and a demo on how to add pagination into WordPress Plugin.

Simple PHP Pagination Class

Copy the following code and save as pager.php, this file will be the pagination class. With this pagination classfrom Happycodings, it’d help us add pagination to the list of records easily.

<?php
function findStart($limit) {
	if ((!isset($_GET['page'])) || ($_GET['page'] == "1")) {
		$start = 0;
		$_GET['page'] = 1;
	} else {
		$start = ($_GET['page']-1) * $limit;
	}
	return $start;
}

/*
 * int findPages (int count, int limit)
 * Returns the number of pages needed based on a count and a limit
 */
function findPages($count, $limit) {
	$pages = (($count % $limit) == 0) ? $count / $limit : floor($count / $limit) + 1; 
	return $pages;
} 

/*
* string pageList (int curpage, int pages)
* Returns a list of pages in the format of "« < [pages] > »"
**/
function pageList($curpage, $pages)
{
	$page_list = ""; 

	/* Print the first and previous page links if necessary */
	if (($curpage != 1) && ($curpage)) {
		$page_list .= ' <a href=" '.$_SERVER['PHP_SELF'].'?page=1" title="First Page">«</a> ';
	} 

	if (($curpage-1) > 0) {
		$page_list .= '<a href=" '.$_SERVER['PHP_SELF']."?page=".($curpage-1).'" title="Previous Page">&lt;</a> ';
	} 

	/* Print the numeric page list; make the current page unlinked and bold */
	for ($i=1; $i<=$pages; $i++) {
		if ($i == $curpage) {
			$page_list .= "<b>".$i."</b>";
		} else {
			$page_list .= '<a href=" '.$_SERVER['PHP_SELF'].'?page='.$i.'" title="Page'.$i.'">'.$i.'</a>';
		}
		$page_list .= " ";
	} 

	/* Print the Next and Last page links if necessary */
	if (($curpage+1) <= $pages) {
		$page_list .= '<a href="'.$_SERVER['PHP_SELF']."?page=".($curpage+1).'" title="Next Page">></a> ';
	} 

	if (($curpage != $pages) && ($pages != 0)) {
		$page_list .= '<a href="'.$_SERVER['PHP_SELF']."?page=".$pages.'" title="Last Page">»</a> ';
	}
	$page_list .= "</td>\n"; 
	return $page_list;
}

/*
* string nextPrev (int curpage, int pages)
* Returns "Previous | Next" string for individual pagination (it's a word!)
*/
function nextPrev($curpage, $pages) {
	$next_prev = ""; 

	if (($curpage-1) <= 0) {
		$next_prev .= "Previous";
	} else {
		$next_prev .= '<a href="'.$_SERVER['PHP_SELF']."?page=".($curpage-1).'">Previous</a>';
	} 

	$next_prev .= " | "; 

	if (($curpage+1) > $pages) {
		$next_prev .= "Next";
	} else {
		$next_prev .= '<a href="'.$_SERVER['PHP_SELF']."?page=".($curpage+1).'">Next</a>';
	}
	return $next_prev;
}
?>

Once you have the pager.php, instantiate the class as below. Change the $limit to your desired number of records to show per page and finally get the page list by echoing it out.

/* Instantiate class */
require_once("pager.php");
$p = new Pager; 

/* Show many results per page? */
$limit = 100; 

/* Find the start depending on $_GET['page'] (declared if it's null) */
$start = $p->findStart($limit); 

/* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */
$count = mysql_num_rows(mysql_query("SELECT field FROM table")); 

/* Find the number of pages based on $count and $limit */
$pages = $p->findPages($count, $limit); 

/* Now we use the LIMIT clause to grab a range of rows */
$result = mysql_query("SELECT * FROM table LIMIT ".$start.", ".$limit); 

/* Now get the page list and echo it */
$pagelist = $p->pageList($_GET['page'], $pages);
echo $pagelist; 

/* Or you can use a simple "Previous | Next" listing if you don't want the numeric page listing */
//$next_prev = $p->nextPrev($_GET['page'], $pages);
//echo $next_prev;
/* From here you can do whatever you want with the data from the $result link. */

Digg Style Pagination

As the above simple pagination class is enough for us to display a list of page numbering for the records, but what will happen if there are a few hundreds of pages, isn’t the row of page numbering going to be very long too?

Here is another nice Digg Style Pagination class that you can consider if you think there will be a lot of pages for your records.

Download the pagination.class.php.

Go through the guide to customize the style or desired output for the paging you want. Now, to give you a clearer view on how to add this Digg Style Pagination class. Check out below to find out how to add the Digg Style Pagination to a WordPress Plugin.

How To Add Pagination To WordPress Plugin?

If you are building a WordPress plugin that require to display a list of records from database. As records get huge, you will need to have pagination so that you can organize your records well.

First, you will need to download the pagination.class.php and save it in your WordPress Plugin folder.

Next, in the PHP file that you want to list your records, insert the following code. Below are some of the methods we used from the pagination class. For the full list of methods, please refer to Digg Style Pagination Class Help Page.

Note that you will need to change the SQL query, pagination class configuration and table fields, in order to work nicely with your WordPress Plugin.

<?php

$items = mysql_num_rows(mysql_query("SELECT * FROM wp_table;")); // number of total rows in the database

if($items > 0) {
	$p = new pagination;
	$p->items($items);
	$p->limit(30); // Limit entries per page
	$p->target("admin.php?page=list_record");
	$p->currentPage($_GET[$p->paging]); // Gets and validates the current page
	$p->calculate(); // Calculates what to show
	$p->parameterName('paging');
	$p->adjacents(1); //No. of page away from the current page

	if(!isset($_GET['paging'])) {
		$p->page = 1;
	} else {
		$p->page = $_GET['paging'];
	}

	//Query for limit paging
	$limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;

} else {
	echo "No Record Found";
}

?>

<!-- Now we'll display the list of records -->

<div class="wrap">
	<h2>List of Records</h2>

	<div class="tablenav">
		<div class='tablenav-pages'>
			<?php echo $p->show(); // Echo out the list of paging. ?>
		</div>
	</div>

	<table class="widefat">
		<thead>
			 <tr>
				 <th>ID</th>
				 <th>Full Name</th>
				 <th>Email</th>
			 </tr>
		</thead>
		<tbody>
		<?php
		$sql = "SELECT * FROM $wp_table ORDER BY id DESC $limit";
		$result = mysql_query($sql) or die ('Error, query failed');

		if (mysql_num_rows($result) > 0 ) {
			while ($row = mysql_fetch_assoc($result)) {
			$id = $row['id'];
			$fullname = $row['fullname'];
			$email = $row['email'];
			?>
			<tr>
				<td><?php echo $id; ?></td>
				<td><?php echo $fullname; ?></td>
				<td><?php echo $email; ?></td>
			</tr>
			<?php 
			}
		} else { ?>
			<tr>
				<td>No Record Found!</td>
			<tr>
		<?php } ?>
		</tbody>
	</table>
</div>

Now you know How to Add a Digg Style Pagination to a WordPress Plugin, it should make your listing of data much more efficient. Pagination saves your time and bandwidth so you can concentrate more on other implementing issues.

Still not sure about this tutorial on adding pagination? Or simply have an idea to share? Feel free to contact us or leave a comment here!

 

 


Adding New Fields to the attachment of wordpress

Recently I was developing plugin for image features. I have to add some fields to the attachment window of wordpress or I can say in Add media box.

We can achieve this by using two hooks of wordpress.
“attachment_fields_to_edit” and “attachment_fields_to_save”;

attachment_fields_to_edit

function get_attachment_fields_to_edit($post,$errors=null){
 // Some Code
 $form_fields = apply_filters("attachment_fields_to_edit", $form_fields, $post);
 // Some Code
 }
  • $form_fields is a special array which will be described in detail in a moment.
  • $post is the attachment as an object (attachments are treated as post objects in WordPress).

attachment_fields_to_save

functionmedia_upload_form_handler(){
	//Some Code
	$post=apply_filters("attachment_fields_to_save",$post,$attachment);
	//Some Code
}
  • $post is the attachment as an array (attachments are treated as post objects in WordPress).
  • $attachment is the attachment part of the form $_POST which will include the fields setup through the attachment_fields_to_edit hook.

Note: Be careful in your code, as $post is sent to one function as an object and to the other as an array.

We will add this fields information to Custom Fields.

How to add this Fields to Custom Fields for Working is Properly

The new fields being added will be saved as post meta, just like the custom fields section of the post/page edit screen. Fields prefixed with an underscore (_my_custom_field) will not be listed in the drop down of available custom fields on the post/page screen; all other existing post meta fields will be listed. We can use this knowledge to hide the fields we’re adding to the media form, since they aren’t relevant for posts/pages.

There is a similar rule to keep in mind when choosing the $form_fields array key to use for your new field. Here, if you use an underscore ($form_fields[‘_my_custom_field’]) your field will be skipped and will not be added to the form.

So in order to show our fields in the media form, but also not list them in the page/post custom fields drop down, we must combine both methods. This will invlove both the edit and save functions we’ll be creating. For the ‘attachment_fields_to_edit‘ hook we’ll set the $form_fields keys up to not have underscore prefixes, and for the ‘attachment_fields_to_save‘ hook we’ll prefix our fields with an underscore before saving them as post meta. This is a workaround worth doing in order to not muddy our users’ interface with unneeded info.

Hook 1: attachment_fields_to_edit

<?php
/**
 * Adding our custom fields to the $form_fields array
 *
 * @param array $form_fields
 * @param object $post
 * @return array
 */
function my_image_attachment_fields_to_edit($form_fields, $post) {
	// $form_fields is a special array of fields to include in the attachment form
	// $post is the attachment record in the database
	// $post->post_type == 'attachment'
	// (attachments are treated as posts in WordPress)
	// add our custom field to the $form_fields array
	// input type="text" name/id="attachments[$attachment->ID][custom1]"
	$form_fields["custom1"] = array(
	"label" => __("Custom Text Field"),
	"input" => "text", // this is default if "input" is omitted
	"value" => get_post_meta($post->ID, "_custom1", true)
	);
	// if you will be adding error messages for your field,
	// then in order to not overwrite them, as they are pre-attached
	// to this array, you would need to set the field up like this:
	$form_fields["custom1"]["label"] = __("Custom Text Field");
	$form_fields["custom1"]["input"] = "text";
	$form_fields["custom1"]["value"] = get_post_meta($post->ID, "_custom1", true);
	return $form_fields;
}
// attach our function to the correct hook
add_filter("attachment_fields_to_edit", "my_image_attachment_fields_to_edit", null, 2);

The $form_fields array has several options for including different types of inputs and custom content. I’ve compiled the various methods below with notes and screenshots of how they render in the form.

Text Input

// input type="text"
$form_fields["custom1"]["label"] = __("Custom Text Field");
$form_fields["custom1"]["input"] = "text"; // this is default if "input" is omitted
$form_fields["custom1"]["value"] = get_post_meta($post->ID, "_custom1", true);

Hook 2: attachment_fields_to_save

Saving your custom fields is a much simpler process than adding them to the form; just check if your field is set and update its value as post meta. Remeber to prefix your field with an underscore when saving to hide it on the post/page edit screen.

/**
 * @param array $post
 * @param array $attachment
 * @return array
 */
function my_image_attachment_fields_to_save($post, $attachment) {
 // $attachment part of the form $_POST ($_POST[attachments][postID])
 // $post attachments wp post array - will be saved after returned
 // $post['post_type'] == 'attachment'
 if( isset($attachment['my_field']) ){
 // update_post_meta(postID, meta_key, meta_value);
 update_post_meta($post['ID'], '_my_field', $attachment['my_field']);
 }
 return $post;
}

You can also add errors here that will automatically be displayed below your field in the form. The$post['errors'] array gets merged with the $form_fields array before being sent through theattachment_fields_to_edit hook.

/**
 * @param array $post
 * @param array $attachment
 * @return array
 */
function my_image_attachment_fields_to_save($post, $attachment) {
 if( isset($attachment['my_field']) ){
 if( trim($attachment['my_field']) == '' ){
 // adding our custom error
 $post['errors']['my_field']['errors'][] = __('Error text here.');
 }else{
 update_post_meta($post['ID'], 'my_field', $attachment['my_field']);
 }
 }
 return $post;
}

Thanks to http://net.tutsplus.com

I have posted here for my future reference.

 

How to make your site listed in major Search Engine

Google

Google is the probably best engine to be listed in. It is one of the most widely searched and they offer tools to help you in designing your page.

There are two things you need to do if you want your page listed in google.

First, submit your site name to the Google add url form. After that, I highly suggest you sign up for their sitemap program. If you need help designing your sitemap to submit, you can use mine and just edit the urls to what you want. The syntax is easy enough to understand, just replace my links with the important pages of your site. Example sitemap is as below:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
	<url>
		<loc>http://www.thedigilife.com/</loc>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>http://www.thedigilife.com/example/</loc>
		<changefreq>monthly</changefreq>
		<priority>0.5</priority>
	</url>
</urlset>

feel free to copy and paste and edit to your liking. Once you are done, place the sitemap.xml in your home directory and submit to Google. The sitemap program will tell you where your page is ranked, what search results show your page, and if your site has any errors, like broken links.

At this point, create a robots.txt file, and place it in your home directory, if you haven’t already made one.
Example robots.txt as below:

User-agent: *
Disallow: /design
Disallow: /africa
Sitemap: http://www.garyshood.com/sitemap.xml

user-agent: googlebot-video
Disallow: /

, when creating yours however, the only line you really need is the following:

User-agent: *

 

Yahoo! & Lycos

Yahoo! is another great engine to have your page listed in. Submit your url again to Yahoo! here. Yahoo! does not have a sitemap program, but there is something similar you can do. If your website runs PHP, there is a script you can use to convert the sitemap.xml you used for Google into a map that you can use for Yahoo!. I read this article to make the yahoo.txt file that can be used as a yahoo sitemap. To do the same, below is the PHP Script.

<?php  
/* 
iELLIOTT.com's Google 2 Yahoo Sitemap Converter 
Version: 1.0 10/31/2005 

Use this script at your own risk.  No Warranty or Support can be provided. 
If you use this script, please give credit to iELLIOTT.com and link back to: 
http://www.ielliott.com/2005/10/31/google-to-yahoo-sitemap/ 

This script is subject to the following license: 
http://creativecommons.org/licenses/by-sa/2.5/ 

CUSTOMIZATION 
============== 
$input_file is the URL location of your exsisting Google sitemap XML file (must end with .xml)   

$output_file is the name of the file you wish to write the Yahoo sitemap data to.  Default is yahoo.txt, but if you've changed the name to something else, it must be reflected here (must end with .txt).  Also be sure that you CHMOD your $output_file to 777 on your server.
*/ 

$input_file = "sitemap.xml"; 
$output_file = "yahoo.txt"; 
?> 

<?php 

set_time_limit(0); 

header("Content-Type: text/plain"); 
echo " Time: ".gmdate("r")."\n"; 
echo "-------------------------------------------------------------\n"; 

$xml = xml_parser_create("UTF-8"); 

xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); 
xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 1); 

xml_set_element_handler($xml, "XMLElementStart", "XMLElementEnd"); 
xml_set_character_data_handler ($xml, "XMLCData"); 

$xml_level = 0; 
$xml_isloc = FALSE; 
$i = 0; 

$fpop = fopen($output_file, "wb"); 
$fp = fopen($input_file, "rb"); 

if ($fp) 
{ 
    while(!feof($fp)) 
    { 
        $s = fgets($fp, 10000); 
        xml_parse($xml, $s); 
    } 
    $ret = xml_parse($xml, "", TRUE); 
    fclose($fp); 
} 
fclose($fpop); 

echo "-------------------------------------------------------------\n"; 
echo " Total $i URLS\n"; 
echo " Time: ".gmdate("r")."\n"; 

function XMLElementStart($xml, $element, $attribs) 
{ 
    global $xml_level, $xml_isloc; 

    $xml_level++; 
    if ($xml_level == 3 && $element == "LOC") $xml_isloc = TRUE; 
} 

function XMLElementEnd($xml, $element) 
{ 
    global $xml_level, $xml_isloc; 

    if ($xml_level == 3 && $element == "LOC") $xml_isloc = FALSE; 
    $xml_level--; 

} 

function XMLCData($xml, $data) 
{ 
    global $xml_level, $xml_isloc, $fpop, $i; 

    if($xml_isloc) 
    { 
        $i++; 
        echo " $data\n"; 
        fwrite($fpop, $data."\n"); 
    } 
} 

?>

Copy and upload it to your server in the same directory as your sitemap.xml. I found this script here. Run the script through your browser, and it will generate a file called yahoo.txt. Example yahoo.txt is as follow:

http://www.thedigilife.com/
http://www.thedigilife.com/example/

After you generate this yahoo.txt file, go to the yahoo submission url again, and for the url, put the location of your yahoo.txt and submit. Lycos is included in this because it uses the Yahoo! search engine to find websites.

 

MSN / Bing

MSN was the quickest to add my site to their search engine. Once again, just submit your site to the MSN add url form here. Soon, if you have AWStats setup or a similar website stat list for your page, you will notice the MSN bot has visited your page and hopefully added you to the index.

 

Ask Jeeves

Ask Jeeves the hardest search engine to be listed in. There is no free add url form for this search engine. You do have the option of paying Ask a fee to be included in the results, but I wouldn’t suggest it, since I have gotten this site in Ask for free, it just took a lot longer. Submit your site to the Open Directory Project here. You have to pick a category for your page and provide a good description on why you should be listed to be accepted. If your site does get popular enough to be listed in the other search engines, there is still a good chance the AskJeeves bot will visit your page and include you in the search directory.

 

Tips To Get Listed

Content is the most important thing to get listed. Search engines will not add your page if you have an “Under Construction” or “Coming Soon” notice on every single page.

The more websites that link to your page, the faster you will get listed. Put your website in your signature in online forums that you visit.

Search engines may take up a week to list you, be patient and make sure you have some type of web stats so you can tell if the bots have visited your site yet.

Note: This Post is for my future use only.