Forum Moderators: martinibuster

Message Too Old, No Replies

is there a css way to do this?

setting AdSense colors and all from a slylesheet

         

annej

8:09 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When I have a great number of pages with identical AsSense code is there a way to do this by putting the adsense code on my seprate slyle sheet then just referring to it from the individual pages. Then when new things come up that require new coding or if I want to change color schemes I could do it from a single code on the style sheet.

I am a beginner in using CSS but if this would work it would sure save a lot of time.

Any CSS experts out there who could help me? I suspect others here would be interested as well.

loanuniverse

8:22 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know nothing of CSS, but I use "Server Side Includes" to display the code in my pages and make it easy to make changes to each of the channels with just one modification.

It takes some work from the point of view of replacing the code in all the pages at once, but I have heard that there are some html editors that can do a quick lookup and replace.

SSI includes using PHP is easy as pie.

annej

9:27 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know that innitially I'd have to recode each page but in the long run it would be easier.

Thanks for the SSI solution. If I can't find a CSS solution I'll look into it. I already am using CSS though so was hoping I could just use that.

If anyone out there is a CSS pro let me know if it's impossible. Maybe I am dreaming.

I know some people love using PHP and this may force me to learn about it.

icedowl

9:47 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm far from a CSS expert as I'm still learning it. One of the best sites that I've found for learning about CSS is mezzoblue's css Zen Garden — Resource Guide.

mack

9:48 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I don't think this can be done with CSS. This is because the ad is not actualy on your page. It is a page on Googles server(s) that is shown within an iframe on your page.

Your iframe is almost like a mini browser displaying the content of a totaly different page.

Maybee someone with a little more CSS knowledge will kill me right off by proving me wrong. lol

Mack.

digitalv

9:53 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Of course you could always "retrieve" the page from Google using an HTTP or XML component (ASP talk - those of you know what I mean can apply this to your language of choice) and save the entire output as a string. Then "replace" portions of the string with what you want to change, and response.write it out to the page.

jomaxx

10:01 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am pretty sure that there is no way to do this in CSS. I am also 111% sure that you will get into all kinds of hot water if you try digitalv's solution. This is a job for PHP or SSI.

danny

11:56 pm on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a job for PHP or SSI

Or static HTML - a one line perl command will change the colours, etc in all your ads!

loanuniverse

12:17 am on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



html can be parsed as php and you can use php includes. That is what I do on my site.

annej

4:06 am on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



SSI includes using PHP is easy as pie.

LU, It looks like your solution is the way to go. Does anyone know of a site where I can go learn how to do it?

One of the best sites that I've found for learning about CSS is mezzoblue's css Zen Garden — Resource Guide.

ID, I've spent hours looking at the sites from Zen Garden. It's fascinating. I hadn't found their resource guide though. I'll have to look.

Thanks everyone for your suggestions and help.

loanuniverse

4:22 am on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well. I can show you how I do mine.

First, if you use htm or html pages you must parse them as php so that the php code can be executed. This is done by changing the MIME types in cpanel. If you use php pages then you can pretty much skip this.

Then you decide where you want the adsense banner and add a line of code as follows:


<?php include('adsense.txt');?>

Then just save your adsense code into the file called adsense.txt and you are ready to go. I think that using includes puts a bit of strain in the server and might slow down delivery a bit, but it is hardly noticeable. However, if you are already stretching the resources on your server is one thing to think about.

4eyes

5:13 am on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Its far simpler - no css or SSI involved.

Just call the first part of the adsense javascript from an external js file.

annej

6:37 am on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



LU, I just figured out that with my server I'd have to rename all my files to shtml for the ssi to work. I don't want to do that as the pages are ranking well in Google so I don't want to change the URLs.

4eyes, Can you explain more how to do it with a java script?

Thanks

birdstuff

11:23 am on Mar 27, 2004 (gmt 0)

10+ Year Member



annej:

If you're using a Linux server, just add these lines to your .htaccess file and you can keep your .html extensions:

Options Includes
AddType text/html .html
AddHandler server-parsed .html

annej

2:30 pm on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just thought of another concern. Would setting the AdSense script on something other than the HTML page would the Google AdSense bot be able to crawl the right page? I'd want to get the good match of ads to page.

The fact I'm even asking this probably shows how clueless I am.

Another question, would adding a mime type extension make it possible to use htm extenders? Maybe I am way over my head here.

Brett_Tabke

3:32 pm on Mar 27, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It can be done via css2 with content after and content before (not supported in ie)

loanuniverse

4:24 pm on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Would setting the AdSense script on something other than the HTML page would the Google AdSense bot be able to crawl the right page?

Lots of us do it like this with no problem. The actual page being served is the "master page" {trademark pending}, the includes become pieces of code.

I do not include the code only. I include a header {with the code as part of it}, a footer, and a side navigation bar. So far no problem... although sometimes, I would see the page hiccup for 1/2 a second before it continues to load, but that is sometimes right at where the adsense code starts. Therefore, I think it is probably Google's fault.

4eyes

7:58 pm on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



4eyes, Can you explain more how to do it with a java script?

When you get your adsense code it comes as two parts, one that resides in your page and one that is called remotely from Google.

You just cut and paste the first part into an external javascript page.

You end up with:


<script language="JavaScript" type="text/javascript" src="http://www.yourdomain.com/js/adsense.js">
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

With the external javascript file being saved in the folder "/js" as a file named 'adsense.js' and containing the following:


google_ad_client = "pub-************xxxxxx";
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = "250x250_as";
google_color_link = "660099";
google_color_url = "000033";
google_color_bg = "FFFFFF";
google_color_text = "000033";
google_color_border = "FFFFFF";

Obviously, with your particular code rather than the above.

All the other solutions seem over complicated to me.

Sharper

8:14 pm on Mar 27, 2004 (gmt 0)

10+ Year Member



4eyes, I used to do as you suggest and was eventually told by Google that they consider it "altering the code" and that I'd have to stop doing it that way.

So I went back to just including the html in all the static files.

Using a server side include of the whole ad code(in any of the various ways) would be acceptable, but I'm not about to make every single page served from my servers have to be processed for SSI by the web service just to include some ad text.

It'd be different if they were already dynamic pages, but they're all static html right now, with very little server load.

4eyes

8:24 pm on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How odd - they told me it was OK

Adsenseadvisor - definitive statement please?

tombola

9:17 pm on Mar 27, 2004 (gmt 0)

10+ Year Member



It can be done via css2 with content after and content before (not supported by ie)

Brett, can you elaborate on this?...

Brett_Tabke

9:22 pm on Mar 27, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



CSS2 Spec: 12.1
[w3.org...]

Authors specify the style and location of generated content with the :before and :after pseudo-elements. As their names indicate, the :before and :after pseudo-elements specify the location of content before and after an element's document tree content. The 'content' property, in conjunction with these pseudo-elements, specifies what is inserted.

For example, the following rule inserts the string "Note: " before the content of every P element whose "class" attribute has the value "note":

P.note:before { content: "Note: " }

Related:
[webmasterworld.com...]

tombola

8:13 am on Mar 28, 2004 (gmt 0)

10+ Year Member



This is a very interesting feature.

Because more than 95% of my visitors use IE browsers, I'm (almost) totally focused on CSS features supported by IE browsers.
It's a shame that IE browsers don't support these pseudo-elements :-(