Archive for the 'Lessons Learned' Category

Adsense Code in Smarty

Saturday, January 6th, 2007

I own several websites that are link directories. Most of them are run on the phpLD Link Directory script. One of the more challenging parts of maintaining and getting these directories going is dealing with Smarty. Before I knew any better, I would get frustrated when trying to add code, then not seeing the end result on the page displayed.

Smarty does weird things, as I’m still learning and understanding.

A prime example of this is adding Adsense code to template files. I was attempting to add Adsense code to one of my templates, and I simply added my Adsense code.

The result was not what I planned. The ads displayed, but were not correct as shown here.(Image at 75% scale)

Adsense Code with Smarty

The ad just didn’t look right, and it seems as though the “ads by Google” text was missing.

After doing some investigating, I learned that I had to add “literal” tags around the code as such:
{literal}
Adsense code
{/literal}

This was much better, as it produced the desired ad:

Adsense ads with code

I still run across confusion when I attempt to do other things similar, and still cannot figure them out. These are growing pains, I’m sure as I will eventually grow out of them.

Changing Header Images Based on Date

Monday, December 25th, 2006

I wanted to “Christmas Up” my forums by changing my header image to something a bit more seasonal. I created a new logo and was curious about automating this change. Maybe I can have different logos for the different seasons, etc.

I looked to the Digital Point Forums and found my answer. A big thanks to JEET who answered my dilemma with the following:

Try this code:
(Assuming your images are stored in a folder called “images”, 1 directory below where the code is executed.)
$mdarr= "18-25/12,13-20/05";
$miarr= "christmas.jpg,happy_birthday_jeet.jpg";

// Format explained below and why use this.

$jtd= date("d");
$jtd= $jtd-7;// Minus 7 days to match above format.
$jtd= $jtd . '-'. date("d"). '/' . date("m");
$jc=0;
$r= explode(",",$mdarr);
foreach($r as $v)
{
if($jtd==$v)
{
++$jc;
}
}
if($jc>0)
{
--$jc;
$img= explode(",", $miarr);
$img= $img[$jc];
print '
'. $img. '
';
}
else
{
print '
default logo
';
}
?>

About the date format.

$mdarr= "18-25/12,13-20/05";
Here you can fit an array for all the dates you wish to change your image on.
For example 25/12 (25 December.) Minus 7 days makes it:
18-25/12, so your image starts appearing 7 days before the actual festival.
Add a "," sign and enter another date in same format.
(Minus 7 days)-(Actual date)/(month)
Add as many as you like.

Which Image to use:
$miarr= "christmas.jpg,happy_birthday_jeet.jpg";

Just enter the full image file name for each date at the same "number" position as it appears in date array.
Seperated by "," sign.

18-25/12 was first item, so "christmas.jpg" is first in this array.
and so on.

Then replace the img tag for your logo with this code above.
Fill the array once, and probably will never have to touch it again...

Submitting Your Sites To Directories…

Tuesday, December 12th, 2006

Submitting your website to directories in an attempt to gain pagerank and/or traffic can be hazardous to your mailbox. While many directory owners have good intentions, some take it to the next level by spamming your email address.

I strongly suggest using an email address that you only use for such applications. Good ones to use are Yahoo, Hotmail or Gmail adresses because they’re quite disposable.

It might also be worht mentioning that just because a directory “Looks Legit” doesn’t mean they will spam you. I have been spammed by some very reputable directory owners.

I’ve posted some of my own link directories in the sidebar, I assure you that you will not be spammed.

Beware Browser Incompatibilities

Monday, December 11th, 2006

As I mentioned in a previous post, I decided to remake a website that was Drupal based, and make is a Wordpress site.

Now you would think that I would learn, because I preach this to others but never remember myself. Before you get too far along in a site, check it with other browsers and resolution settings.

Once again, I took it for granted.

I got pretty far into my new Wordpress theme. I was near three hours into recoding and rebuilding this site until I had to go to work. At my “Real Job” I was checking on some things using a different computer. My stomach sank when I looked at my new site and it was half gone.

I realized that using the Liquid Summer 1.0 theme, it looks awesome with Firefox but with Internet Explorer, forget it. I decided quickly that I would be better off just scrapping and starting with a different theme than to try to make this one work.

Drupal Backend is Awful!

Sunday, December 10th, 2006

I recently purchased two Drupal based websites. One of them is Pet Search Engine and is a real fix me upper.

As I went in the back end and was attempting to make changes, I was completely unimpressed with how the system works. It almost feels like they’re trying to do too much and leaves the administrator completely confused. I tinkered around for several hours and am still finding things.

The navigational system in there is bad also. In fact, I am so displeased with it, I am leaning towards scrapping the entire site and starting fresh with a Wordpress based site.