About impNERD

impNERD is the place to find information on internet marketing, publishing and tips for web development. Read more »

Subscribe

Subscribe to impNERD via RSS
What is RSS?
Subscribe via e-mail:

What I’ve Learned About StumbleUpon

I love StumbleUpon. SU a great way to find new sites and photos, one of my favorite free-time activities. So as you might imagine, I’ve used it a ton in 2007—over 4,500 thumbs up, many thumbs down and hundreds of reviews.

With the great power StumbleUpon holds, it has played an important role in getting impNERD’s feet off the ground. One article alone received over 20,000 unique SU visitors and is still receiving more daily.

As a result, I have learned much about StumbleUpon over the past year

  • Stumblers love photographs – both the category and in user blogs.
  • The buzz pages aren’t used often.
  • The more fans and stumbles you have the more people will view a page you stumble.
  • Stumblers do subscribe to RSS feeds, usually from the address bar and not by clicking on-page graphics.
  • Tags (keywords) matter. The more general the better.
  • One article gone hot will give you more fans than visiting and rating users pages.
  • Saying “thank you” for a stumble will likely result in longer stays and the likelyhood of them doing so again.

Add to Del.cio.us RSS Feed Stumble It! Zoom It! Add to Sphinn
    www.sajithmr.com


Articles, articles… articles!

There have been some great articles the past week, so let’s get started!

A Game in plain HTML (no JavaScript, no Flash, no PHP)

Programmers food pyramid

Dirty trick to steal digg traffic and not get banned

inhabitat.com has a story about Cell phones running on hydrogen

Muhammad Saleem came up big with two great stories:
- 9 reasons why the digg story sells
- 7 Tips To Win The Social News Beauty Pageant

turnipofpower (if you are a nerd like me you might think it is turn ip of power, but I assure you it is actually turnip of power… interesting eh?) is starting an article series entitled “Making Money Through Affiliates”, here’s the first article: Niche Blogging Experiment Part 1. It is something we should all keep an eye on.

Add to Del.cio.us RSS Feed Stumble It! Zoom It! Add to Sphinn
    www.sajithmr.com


10 Lovely Valentine’s Day Wallpapers

Love is in the air! Or is that just the burrito I ate this afternoon? Well either way, Valentine’s day is approaching quickly. So what does that mean? You’ve guessed it! Free Valentine’s day wallpapers for everyone’s desktop. There’s even a special one for those who just hate Valentine’s. So here they are, 10 backgrounds for everyone’s desktop.

Valentine’s Day Backgrounds

My Dancing Heart… Happy Valentine…

Happy Valentine's Day

heart-Wallpaper-1280x800

Cats and Dogs

Happy Valentine's Day!

Love Coffee

True Love

Colorful Daisies

Heart

And for those who hate Valentine’s Day

Don't Break My Heart Close Up

Brrr, it’s still cold outside. Maybe after V-Day we’ll have to go back to the winter wallpaper.

Until then, happy Valentine’s day!

Add to Del.cio.us RSS Feed Stumble It! Zoom It! Add to Sphinn
    www.sajithmr.com


Featured Posts Plugin for WordPress

You’ve probably seen websites with featured posts or breaking news at the top and wondered how to do it. Well now you can easily add it to the front page of your WordPress blog or any category.

Why might you want to do it?
Sometimes you want your visitors to see a post but want to continue adding new content at the same time. For example, you are running a contest and want your visitors to see it first thing, but you want to continue writing about your regular subject. A great way to help your visitors see it is to use featured posts. You just type in the id of your post within the plugin options page and all your regular articles will be displayed normally.

How easy is it to install?
Extremely easy! Just download the file, upload it to your directory and head to the options page. There you enter the post ID you wish to be displayed and whatever image you wish to be shown.

You can easily add images by uploading them to the featured-posts/images folder (recommended size is 233×175). example ads are from my flickr account

What it looks like in the admin:
Admin screenshot

Wonder what it looks like on your frontpage:
Index screenshot

Can I change how it looks?
You can also easily change the look and feel of the plugin within the separate CSS file so you don’t have to dig through the plugin to find it. This can be extremely useful if your site is using obscure percentages or you want to change the size of the featured posts box.

Do I have to show an image?
No, but it does look better with one. To not show an image just select “do not show image” within the plugin options page. After doing so you may need to change the CSS though, otherwise the featured posts plugin will leave a lot of whitespace underneath.

How do I show the plugin on my homepage only?
<?php if (is_home()) { if(function_exists(’featuredposts’)) featuredposts(); } ?>

How do I show the plugin on a specific category?
<?php if (is_category(’5′)) { if(function_exists(’featuredposts’)) featuredposts(); } ?>

Want to try Featured Posts?
Download Featured Posts 0.1

Add to Del.cio.us RSS Feed Stumble It! Zoom It! Add to Sphinn
    www.sajithmr.com


3 Easy Ways to Create Templates

Templates are a great way to cut down on development time. Instead of writing the same HTML or PHP within several pages, templates allow you to use the same code multiple times with a short bit of code.

The include


<?php
include('bug.php');
?>

Pretty simple idea. Create a header.php file and a footer.php file. Then at the top of each page you create copy and paste this code changing ‘bug.php’ to ‘header.php’ and copy and past again at the bottom changing ‘bug.php’ to ‘footer.php’.

The great thing about using include is that it is powerful. You can create variables within the header.php and footer.php and pass them from the file with the includes.

For example:
header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<?php
echo '<title>',$title,'</title>';
echo '<meta name="keywords" content="' ,$keywords, '" />';
echo '<meta name="description" content="'.$description,'" />';
require_once('geoip.php');
?>
</head>
<body>

footer.php

</body>
</html>

index.php

<?php
$title = 'Title of page here';
$keywords = 'keywords, keywords, keywords';
$description = 'The description of the page';
include('header.php');
?>

<h1>Header of page</h1>
Page content, page content, page content

<?php
include('footer.php');
?>

The template engine


<?php
//The engine itself:
print preg_replace("/\{([^\{]{1,100}?)\}/e”,”$$1″,file_get_contents(”template.tpl”));
//Format of template.tpl file:
<html>
<head>
<title>{title}</title>
</head>
<body>
<h1>{header}</h1>
{text}
</body>
</html>
//Setting variables:
$title=’Title of page’;
$header=’Headers’;
$text=”Place holders get replaced.”;
//If you’re not comfortable with pulling variables out of the global scope, define them as $values['title']=”..”; etc., and use:
print preg_replace(”/\{([^\{]{1,100}?)\}/e”,”$values[$1]“,file_get_contents(”template.tpl”));
?>

“/\{([^\{]{1,100}?)\}/e”,”$$1″
The regular expression is delimited by // while using the modifier ‘e’ to cause the second argument to be evaluated by PHP.

The pattern looks for the entry brace (\{) and ending with (\}). In between the two braces it searches for all characters that are not an opening curly-brace. The code then matches between 1 and 100 non-{ characters and searches for the shortest strings. The full string is then stored within $1 and surrounded by (). The second argument of preg_replace is “$$1″ which is variable variables. If the pattern finds “{title}” then the matched string $1 is “title” and so $$1 is called $title.

This is the one class template engine:

<?php
class Template {
var $data = array();
function __construct($directory) {
$this->directory = $directory;
}
function set($key, $value = NULL) {
if (!is_array($key)) {
$this->data[$key] = $value;
} else {
$this->data = array_merge($this->data, $key);
}
}
function fetch($filename, $directory = DIR_TEMPLATE) {
$file = $directory . $this->directory . ‘/’ . $filename;
if (file_exists($file)) {
extract($this->data);
ob_start();
include($file);
$content = ob_get_contents();
ob_end_clean();
return $content;
} else {
exit(’Error: Template ‘ . $file . ‘ not found!’);
}
}
}
?>

Format of template.tpl file:

<html>
<head>
<title>{title}</title>
</head>
<body>
<h1>{header}</h1>
{text}
</body>
</html>

Your ‘main’ file, let’s call it index.php:

<?php
// Figure out which page to load
$page = 'index';
if(!empty($_GET['page']) && ctype_alnum(trim($_GET['page'])))
$page = trim($_GET['page']);
// Get the variables for the page to be loaded
if($page == ‘index’)
{
$title = ‘Index Page Title’;
$header = ‘Header of Page’;
$text = ‘All the page\’s content.’;
}
elseif($page == ‘about’)
{
$title = ‘About Us’;
$header = ‘Info About Us’;
$text = ‘Content of about page.’;
}
else
{
$title = ‘Error: Page Doesn\’t Exist’;
$header = ‘Sorry, the page you requested doesn\’t exist’;
$text = ”;
}
// Run the template engine
print preg_replace(”/\{([^\{]{1,100}?)\}/e”,”$$1″,file_get_contents(”template.tpl”));
?>

The first checks if a page argument exists and if it is alpha-numberic. The next part defines the variables of each page, including an error page, then tells the template to grab each page.
The pages will be called by mywebsite.com/index.php or example.com/index.php?page=about
To change the way the url is displayed for an easier way for visitors to remember you should use a 301 within your .htaccess file.

Another way to use the same template.tpl file is to create three separate pages:

index.php

<?php
$title = 'Index Title';
$header = 'Header of Page';
$text = 'All the page\'s text and info.';
print preg_replace("/\{([^\{]{1,100}?)\}/e”,”$$1″,file_get_contents(”template.tpl”));
?>

about.php

<?php
$title = 'About Us';
$header = 'Info About Us';
$text = 'We are the greatest, yada yada';
print preg_replace("/\{([^\{]{1,100}?)\}/e”,”$$1″,file_get_contents(”template.tpl”));
?>

Then just load the pages as normal – mywebsite.com/index.php, mywebsite.com/about.php

Add to Del.cio.us RSS Feed Stumble It! Zoom It! Add to Sphinn
    www.sajithmr.com


Sponsors

Hosting Concept
Make money online
PoemofQuotes Blog