Adsense Tweaks
August 22, 2005 on 9:54 pm | In 31 Days to a Better Blog, AdSense, Blog Housekeeping, Blogging | No CommentsI have been mentioning for a few days that I have been spending some time Tweaking the AdSense that appears here and on my Nicolas Darvas Website.
One of the biggest tasks was placing an 250 x 250 AdSense Box that appeared in just the first post of a displayed web page. If anyone is inerested in doing this themselves, then here is a brief description of how I did it.
The most important thing was to hack the index.php file in the current theme. What I needed to achieve was to insert the AdSense box into only the first post and not any of the subsequent ones.
So, to achieve this, I had to put a counter variable at the begining of the index.php file – I hope it doesn’t get too geeky!:
< ?php $showAdSense = True; ?>
Next, I had to scroll down through index.php to find the start of the <div> tag which handles the style for each post – In my current Theme, it is:
<div class=”entry”>
Once I had found this, I pasted my AdSense code immediately before it – with some PHP and a style wrapped around it – The PHP made sure only one block would be displayed and the style would place it in the right area of the post. Here is the code:
<?php If ($showAdSense) { ?>
<div style=”float: right; margin: 0px; margin-top: 10px; padding-right: 0px; padding-left: 5px”>
<script type=”text/javascript”><!–
google_ad_client = “pub-XXXXXXXXXXXXXXXX”;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = “250×250_as”;
google_ad_type = “text”;
google_ad_channel =”";
google_color_border = “FFFFFF”;
google_color_bg = “FFFFFF”;
google_color_link = “CC6600″;
google_color_url = “6699CC”;
google_color_text = “000000″;
//–></script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
</div>
<?php $showAdSense = False;} ?>
Basically, the first line of this code asks is there an AdSense Box here?. Because the showAdSense variable is set to True – then the answer to this question is Yes – so, the AdSense code is inserted into the HTML for the page.
At the end of the AdSense insertion, there is a piece of PHP code that then sets the showAdSense variable to False – so that the when it comes to insert the next post and the page asks if there is an AdSense box – the answer will be No.
And that – believe it or not – is all there is to it. Of course don’t be fooled by how easy it is – Remember to ALWAYS back-up any files you are working on when Hacking your Blogging Software. I know from bitter experience the pain of trying to unpick crappy code because you can’t restore to the original version.
Oh – and I’ve inserted all those XXXXXXXX’s in the AdSense block where my AdSense ID goes. If you would really like to show my ads on your pages – please let me know as I’ll be only to happy to oblige!
Related Posts:
3.28767 is the first Google AdSense Magic Number
Michael Cheneys AdSense Videos (Update)
Michael Cheneys AdSense Videos
AdSenseLog – Desktop AdSense Account Application
Chitika eMiniMalls
Day 18 – Roundup
August 18, 2005 on 10:27 pm | In 31 Days to a Better Blog, Blog Housekeeping, Blogging | No Comments
Related Posts:
Day 20 & 21 – Roundup
Day 7 – Roundup
Day 15 – Roundup
Day 9 – Roundup
Day 16 – Roundup
Web Hosting Offer
August 18, 2005 on 12:28 pm | In 31 Days to a Better Blog, Blog Housekeeping, Blogging | No Comments
Related Posts:
Website Hosting – Dreamhost Sale
GoDaddy
GoDaddy Again
Color Wheel Pro
Link Building – An Open Invitation
Style Sheet Update
August 12, 2005 on 10:28 pm | In 31 Days to a Better Blog, Blog Housekeeping, Blogging | No Comments
Related Posts:
Day 11 – Roundup
Day 12 – Roundup
Google PageRank
Monday morning is a quiet day in New Zealand.
Michael Cheneys AdSense Videos (Update)
Day 12 – Roundup
August 12, 2005 on 10:20 pm | In 31 Days to a Better Blog, Blog Housekeeping, Blogging | No Comments
Related Posts:
Day 20 & 21 – Roundup
Day 7 – Roundup
Day 15 – Roundup
Day 9 – Roundup
Day 16 – Roundup
Day 11 – Roundup
August 12, 2005 on 10:04 am | In 31 Days to a Better Blog, Blog Housekeeping, Etc... | No Comments
Related Posts:
Day 20 & 21 – Roundup
Day 7 – Roundup
Day 15 – Roundup
Day 9 – Roundup
Day 16 – Roundup
Day 8 – Roundup
August 8, 2005 on 9:14 pm | In 31 Days to a Better Blog, Blog Housekeeping, Blogging | 1 Comment
Related Posts:
Day 20 & 21 – Roundup
Day 7 – Roundup
Day 15 – Roundup
Day 9 – Roundup
Day 16 – Roundup
Blog Stubs
August 6, 2005 on 10:16 am | In 31 Days to a Better Blog, Blog Housekeeping, Blogging | 2 Comments
Related Posts:
Day 6 – Roundup
Day 18 – Roundup
Meme
Edward de Bono – The Six Value Medals
Day 12 – Roundup
Color Wheel Pro
August 5, 2005 on 8:52 pm | In 31 Days to a Better Blog, Blog Housekeeping, Blogging, Tools | 1 Comment
Related Posts:
Day 6 – Roundup
31 Days to Building a Better Blog
AdSenseLog – Desktop AdSense Account Application
Wheelspin and Traction
faveicon.ico
August 3, 2005 on 9:40 pm | In 31 Days to a Better Blog, Blog Housekeeping, Blogging | 2 Comments
Related Posts:
Day 3 – Roundup
Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^








