PDA

View Full Version : Insert Google Adsense Ads into Articles


falsealarm
07-10-2007, 04:24 AM
Has anyone attempted to insert Adsense ads in to articles by splitting the articles in the middle or every so many sentences?

David
07-10-2007, 06:30 AM
I don't know of anyone that has done this on phpLD articles.

proprod
07-10-2007, 08:45 AM
I have not split them... but I've added adsense to the article pages.

This sort of reminds me of "add ads after this many listings" on aardvark topsites. It can be done. Do I know how to do it off hand? No... can I figure it out it a few days? Probably, hehe... give me a bit on this one. If I do not reply if the next few days, dawzz will, he's got that radar ;)

Freewebspace
07-10-2007, 01:42 PM
Content visible to registered users only.


I would definitely give a try!

falsealarm
07-10-2007, 04:32 PM
If my understanding of Php and Smarty was not so limited, I could have completed this long time ago. I can not decide whether this needs to go in the article.php or the article.tpl and do not know which string function it needs to call.
Obvisouly not susbtr as it seems to splits by characters and not sentences or paragraphs. Is it explode? chunk_split?
All it needs to do is split the ARTICLE into two print section 1 first, insert reference to a googlead.tpl and print section 2.

fredofredo
07-10-2007, 04:41 PM
hello falsealarm (http://www.phplinkdirectory.com/forum/member.php?u=9140)

Insert <!--- Ads ---> where you want to split the articles
Insert by "Quellecode" in your editor
i dosent know the Word in english

open article.tpl

find

falsealarm
07-10-2007, 06:19 PM
Fredofredo, Thanks for the rely. I will give this a try and it seems like it would work. The only issue is that I would have to insert the <!--- Ads ---> tag into my articles manually.
I am hoping to find an automated resolution to this. However, I do agree to that your solution would work and thank you for taking the time to post.

falsealarm
07-11-2007, 03:52 AM
The above recommended method actually did not work. I can see the Adsense code in the page source however the ads will not display.
Tried to split via split_str in the article.php however that did not work either which may be due to html code in the article source. Does anyone any idea? At least a pointer or two?

jayg
07-11-2007, 06:01 AM
Can't you just add it to the article in source view?

falsealarm
07-11-2007, 05:34 PM
I guess I am going to have to resort to that. Sad.

Content visible to registered users only.

David
07-11-2007, 05:44 PM
I'll try to do this in the new phpLD Article script, and then maybe we can publish the code for how we did it. It is sometimes hard to satisfy every mod request unfortunately.

jayg
07-11-2007, 06:00 PM
I just inserted it into the code, you can see it here http://www.topurlsearch.com/articles/article-10.html

Update: I am now having trouble accessing those articles, something is wrong. I PM'ed David and am awaiting some help. So maybe you should not do it manually yet.

falsealarm
07-11-2007, 08:34 PM
Jayg,
Yes, I agree when manually inserted it works. But I was hoping to add much more than 10 articles after go-live. This would have been a great addition.
I am hoping to figure out a way to split the text after an X number of paragraphs on the tpl side. If I can figure out how to do that than I will post it here.

falsealarm
07-12-2007, 05:09 AM
Jayg, I was actually going to reply saying that once the script is added the articles become uneditable via TinyMCE but you seem to have found that out already. You will need to modify the article in the database and remove the script from the source.
The best method is fredofredo's which I later managed to implement correctly.

Content visible to registered users only.

James
07-12-2007, 05:24 AM
If you have to edit it then just go to settings >> admin area>> and set the rich text editer to No edit the document to remove the adsense and then re enable the editer.

James
07-12-2007, 05:28 AM
I also would recommend the above method using the replace over trying to count paragraphs .. it would be easy to make a mistake and end up with way to many ads on one page.

falsealarm
07-12-2007, 05:59 AM
That's exactly what I ended up with by trying simple solutions on the tpl side. I am sure something can be done in article.php but limited php knowledge prevents me from coming up with that smart solution. :)


Content visible to registered users only.

James
07-12-2007, 06:09 AM
There is no smart solution when trying to figure out how to split up a page.

You would need an absolute to be able to count them right the topsites and forums all have an absolute to count ... a post or and ad .. some thing that is the same, that you can count. In the article there is nothing. The way posted above will be the best way to do it. You can get fancy with a smarty function but in essence the way shown is the easiest to implement.

fredofredo
07-12-2007, 06:21 PM
next way to split the articles

add a new field to database
edit File article_edit.tpl
and add a <tr> like
<tr>
<td class="label"><label for="ARTICLE">{l}Article{/l}:</label></td>

jayg
07-12-2007, 07:12 PM
If I just want put adsense only at the bottom of each article is there an easy way to do it?

YIAM
07-12-2007, 07:28 PM
Content visible to registered users only.

In article.tpl, just add
Content visible to registered users only.After
Content visible to registered users only.

falsealarm
07-12-2007, 07:31 PM
Placing the ads below the articles would be a waste of time and would dilute your click ratio. Most people do not normally read an article in whole. The article logically should go in between the second and third paragraph.
If you have to add below the article, the best method to do so is to create a googlead.tpl with your Adsense code in it and in your article.tpl do an include for it.

jayg
07-12-2007, 07:54 PM
I guess I just don't want the adsense code to be annoying or leave a bad impression with my visitors. I think I will wait and see if my articles get enough traffic to justify even placing the code.

thanks