Forum Moderators: martinibuster

Message Too Old, No Replies

Adsense Multiple Themes Problem

         

mxmaster

1:01 pm on Jul 4, 2007 (gmt 0)

10+ Year Member



Hello there,

I have Google adsense on my site and everything is working perfectly, the problem I need solving is if there is a way of adding multiple themes based on what .css style sheet is in use.

I'm not too canny on Javascript but hear it can be done this way.

For example:

If user has 'GREEN.css' theme selected on my website I want google adsense colors to be...well Greeny in color.

If the user selected the 'BLUE.css' theme selected on my website, then I want my google adsense colors to dynamically change to a Bluey theme.

At the min, I can only choose one set of colors!

I have browsed the forum and saw this post: [webmasterworld.com ]

And wondered if anyone could expand on what jouwpagina says about this:

google_color_bg = "<?
if($style=="black")
echo"000000";
elseif($style=="white")
echo"FFFFFF";
elseif($style=="green")
echo"*******";
?>";

Like I said, its a grey area Javascript to me but if someone could type a script for me to copy and paste, then I could upload it as a .js file

and also edit the google theme script accordingly (Not the code though as I know this is naughty) I would be most greatful.

Thanks

MXMaster

shogun_ro

1:16 pm on Jul 4, 2007 (gmt 0)

10+ Year Member



I'll do this way:

1. Generate different ad code for every theme, and put in separate file.

2. Where you need the code just include the file.

mxmaster

1:40 pm on Jul 4, 2007 (gmt 0)

10+ Year Member



I don't see how that can work... Can you expand on this?

I understand the 'include' function, but my users are switching color schemes on my website by simply switching .css style sheets. I don't have two different web pages for each color theme.

As in:

I don't have 'blue_index.php' and 'green_index.php'

My style sheets look like this:

<link href="../css/css.css" rel="stylesheet" title="none" type="text/css"/>
<link rel="alternate stylesheet" type="text/css" media="screen" title="white-theme" href="../css/white.css" />

Thanks for replying and I wait to hear more...

MX

wheelie34

2:11 pm on Jul 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't have 'blue_index.php' and 'green_index.php'

He means have the adsense code in include files and when the user selects the green theme include your green.css file AND the green_index.php for the ads.

All you need in the green_index.php is the green ad code.

shogun_ro

2:14 pm on Jul 4, 2007 (gmt 0)

10+ Year Member



Exactly!
Thank you wheelie34.

mxmaster

2:23 pm on Jul 4, 2007 (gmt 0)

10+ Year Member



Thanks both for replying...

Could you write what the 'include' command would look like on my page.

Or what I would need to add to the HEAD of my page...

Thanks again...

MX

wheelie34

3:16 pm on Jul 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your pages are php pages then this will work

<? include ("green_index.php")?>

You dont need to call the include files green_index.php etc, I would just call them green_ads.txt or green_ads.php as either will work for what you are doing.

If your pages are not php you have a few options, either in your htaccess file set it so it will parse php on a html page or use ssi to include the file.

mxmaster

3:49 pm on Jul 4, 2007 (gmt 0)

10+ Year Member



Thanks for replying,

I understand the 'include' you have wrote but still can't see how to link this with my .css files?

My webpage uses a Javascript command to 'switch' style sheets at the click of a button without changing the page source code.

So I can click green.css and all my page looks green, or I can click the link to switch the page to blue.css so my page looks blue.

If I insert the 'include' to my page and the user 'switches' style sheets giving a different theme, the same Green_ads.php include will still be there... hence, still look 'green'. Even though the page is now showing the 'blue' style sheet.

See what I mean?

I would love to post the link to the webpage to show you but I can't.

Hope this makes sense.

MX

wheelie34

5:18 pm on Jul 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So I guess the page doesn't reload when they select the colour they want?

Maybe you could ask in the css forum

[webmasterworld.com ]

You can sticky me the URL if you want.

FourDegreez

12:27 am on Jul 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you figure out a way to use javascript to reload the AdSense blocks in a new color on a static page, there could be TOS implications to that. I don't think you're supposed to refresh the ads on a static page. And I don't think you can get the colors to change without causing the ads to reload.

I solve this problem the PHP way that was described above. Every css file has a matching PHP include file, with functions like show160x800ad(), show250x250ad(), etc.

acunat

2:42 am on Feb 19, 2008 (gmt 0)

10+ Year Member



Hey,

Has anyone figured this out yet? I've been searching for a while and can't find a solution. Just like mxmaster I'm new to php and my site is using a css switcher. If anyone has a solution, could you help me out with a fairly detailed fix? Thanks!