1
thepaul
Adsense embedded in News
  • 2006/10/2 21:55

  • thepaul

  • Just popping in

  • Posts: 12

  • Since: 2006/6/20


How would I embed an adsense codeblock to show up after the first news post?

i.e.

News Item 1
Adsense ad
News Item 2
News Item 3
News Item 4
News Item 5

2
limecity
Re: Adsense embedded in News
  • 2006/10/3 4:17

  • limecity

  • Friend of XOOPS

  • Posts: 1602

  • Since: 2003/7/6 0


perhaps you can try hacking the template for news
hhttp://www.mounthiking.com
all your hiking gears and gadgets


3
love2know
Re: Adsense embedded in News
  • 2006/10/3 12:31

  • love2know

  • Just popping in

  • Posts: 35

  • Since: 2006/7/28


Which news template file do you hack? is it the news_article.html or news_item.html?

do you just paste the google code inside?

4
acegamer
Re: Adsense embedded in News
  • 2006/10/3 13:50

  • acegamer

  • Not too shy to talk

  • Posts: 162

  • Since: 2005/7/11


Mmm, nice idea but how do you hack this exactly?


Thx,

AceG.

5
thepaul
Re: Adsense embedded in News
  • 2006/10/3 18:10

  • thepaul

  • Just popping in

  • Posts: 12

  • Since: 2006/6/20


You need to find where it loops through the db records and displays them on the page, then you just insert the google code after the first iteration. Should not be dificult.

Problem is the source code is split over multiple php, class and template html files...

I am a software engineer, but was hoping for someone who is familiar with the codebass would give me a headstart.

6
wizanda
Re: Adsense embedded in News
  • 2006/10/3 18:52

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


Shouldn't be hard to find...just work your way from where you are looking at on the module is what i do...so like if its the index.php see what is needed and linked to from there...

Yet the main template would be likely for the html part...

Don't understand why not the XOOPS banner, yet still... good luck you will need it...can't stand them ad's everywhere yet that is me...

7
tcnet
Re: Adsense embedded in News
  • 2006/10/5 18:59

  • tcnet

  • Friend of XOOPS

  • Posts: 297

  • Since: 2006/5/12


To display adsense code after the first news story

For Classic view, edit news/templates/news_index.html

Change the table from:
<table width='100%' border='0'>
<
tr>
<{
section name=i loop=$columns}>    
<
td width="<{$columnwidth}>%">
<{foreach 
item=story from=$columns[i]}>        
<{include 
file="db:news_item.html" story=$story}>
<{/foreach}>
td>
<{/
section}>    
tr>
table>


to:

<table width='100%' border='0'>
<
tr>
<{
counter start=print=false assign=storycount}>
<{
section name=i loop=$columns}>    
<
td width="<{$columnwidth}>%">
<{foreach 
item=story from=$columns[i]}>        
<{include 
file="db:news_item.html" story=$story}>
<{if 
$storycount == 0}>

<
script type="text/javascript">
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
script>

<{
counter}>
<{/if}>
<{/foreach}>
td>
<{/
section}>    
tr>
table>


If you show News by Topic in your index you could display an ad after the first topic by editing news/templates/news_by_topic.html

Look around line 25 for the end of the loops:
div><br />
<{/foreach}>    
td>
<{/
section}>


and change it to:
div><br />
<{if 
$storycount == 0}>

<
script type="text/javascript">
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
script>

<
br /><br />
<{/if}>
<{
counter start=print=false assign=storycount}>
<{
counter}>        
<{/foreach}>    
td>
<{/
section}>


This should work with all versions, but has only been tested on my local with XOOPS 2.2.4.

Good Luck!

8
acegamer
Re: Adsense embedded in News
  • 2006/10/6 19:49

  • acegamer

  • Not too shy to talk

  • Posts: 162

  • Since: 2005/7/11


thx i will try it ..

9
love2know
Re: Adsense embedded in News
  • 2006/10/6 23:34

  • love2know

  • Just popping in

  • Posts: 35

  • Since: 2006/7/28


Great suggestion tcnet.. very much appreciated..

However, I've been having trouble actually embedding adsense within each article itself..

any suggestions?

10
tcnet
Re: Adsense embedded in News
  • 2006/10/7 12:25

  • tcnet

  • Friend of XOOPS

  • Posts: 297

  • Since: 2006/5/12


@Love2Know

Edit news/templates/news_article.html to display ads on each news article.

or

After reviewing your site it looks like you would like to display ads on the top of all news module pages. Rather than modify all of your news templates, another solution would be to put your adsense code in a custom block and assign it to the center top block of all News module pages.

My site displays custom block's with ads at top and bottom of all News pages. Example Here.

I have removed my custom block's title and div by modifing theme/blocks/ *.html template with...
<{if $block.title != ""}>
<
div class="blockTitle">
<{
$block.title}>
div>
<{/if}>

and leaving the block's title blank when created.

Happy Xoopsing!

Login

Who's Online

241 user(s) are online (172 user(s) are browsing Support Forums)


Members: 0


Guests: 241


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits