Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Plugin - Random Adsense in Listings

Quote Reply
Plugin - Random Adsense in Listings
Hi there,

Any thoughts on how to randomly display an Adsense Advert in a Category of Links?
i.e. At the moment I can put them in the header, footer, side bar etc, but I would like to mix them into a random position within my list of links on any page where there are links. FYI The links are sorted alphabetically.

So something like get the count of links in a category and then chose a random position for the Adsense code from that number and then display it in a page.

Don't know if this is possible?


Cheers,

Piers
Quote Reply
Re: [Piers1] Plugin - Random Adsense in Listings In reply to
Mmm.. could probably do it in category.html, with:

New Global: get_random_place_to_put_ad

Code:
sub {

my $cat_id = $_[0];

my $tbl = $DB->table('CatLinks','Links');
$tbl->select_options('ORDER BY RAND()','LIMIT 1');

my $id_pos = $tbl->select( { CategoryID => $cat_id } )->fetchrow_hashref;

return { ID_To_Put_Ad_At => $id_pos->{ID} }

}

Call with:

1) At the top of category.html:

<%get_random_place_to_put_ad($category_id)%>

..then, in link.html -

Code:
<%if $ID eq $ID_To_Put_Ad_At%>
..show adsense code here
<%endif%>

Untested, but hopefully that'll work :)

It should select a random link ID, and then, in link.html you can put the adsense code in.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: May 12, 2008, 1:37 AM
Quote Reply
Re: [Andy] Plugin - Random Adsense in Listings In reply to
ok - when I put the last piece of code into link.html (at the top) I get the same random repeating link. It repeats the same number of times as there are links in the category.
If I put it into the bottom of link.html, I don't get anything.

So it feels like its almost there, but not quite.....

Cheers,

Piers
Quote Reply
Re: [Piers1] Plugin - Random Adsense in Listings In reply to
Hi,

Can you send over FTP details, and I'll have a look for you?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Piers1] Plugin - Random Adsense in Listings In reply to
Hi,

LOL, worked it out <G>

Change:

Code:
return { ID_To_Put_Ad_At => $id_pos }

..to:

Code:
return { ID_To_Put_Ad_At => $id_pos->{ID} }

I've done some tests on my dev install, and it works perfectly :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugin - Random Adsense in Listings In reply to
Perfect! - I think this might be very useful to other people.

I'll try it for a while and see how much of a response I get.

Many thanks,

Piers
Quote Reply
Re: [Piers1] Plugin - Random Adsense in Listings In reply to
Hi,

Glad its working :)

I think I may add this into ULTRAGlobals too - cos it could be useful to others Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: May 12, 2008, 1:39 AM
Quote Reply
Re: [Andy] Plugin - Random Adsense in Listings In reply to
What would I change if I wanted the Ad to appear between the first 6 links or top fold of page?

Thanks!
Quote Reply
Re: [Soren] Plugin - Random Adsense in Listings In reply to
Are you doing this with my plugin, or a global?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugin - Random Adsense in Listings In reply to
I was using your plugin Smile I can change to a global if that will be easier to make the change

Thanks Andy!
Quote Reply
Re: [Soren] Plugin - Random Adsense in Listings In reply to
Ok, well to change it so that it only shows after the first 6 links, just edit your link.html. Add:

Code:
<%if row_num = 6%>
..advert code here
<%endif%>

That should do it :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugin - Random Adsense in Listings In reply to
Dude that little piece is awesome. It just opened up new design & interface options.

Vishal

-------------------------------------------------------
Web Hosting Kit: A to Z of Web Hosting! http://www.webhostingkit.com/
Software Devil: Software Search Made Easy! http://www.softwaredevil.com/
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Plugin - Random Adsense in Listings In reply to
heheh I've been using it for years :) (on my-free-css-templates.com, so it shows adverts every xx records)

Chneers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugin - Random Adsense in Listings In reply to
Thanks! That is great :) Care to share the code to make it appear after every xx links?
Quote Reply
Re: [Soren] Plugin - Random Adsense in Listings In reply to
If you wanna do it every 5 links, for example - just re-use the same kinda code:

Code:
<%if row_num == 5 or row_num == 10 or row_num == 15 or row_num == 20 or row_num == 25%>
..show code here
<%endif%>

Obviously this assumes you have 25 records per page (as standard)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugin - Random Adsense in Listings In reply to
Thanks!!!
Quote Reply
Re: [Andy] Plugin - Random Adsense in Listings In reply to
  

Andy wrote:
If you wanna do it every 5 links, for example - just re-use the same kinda code:
Code:
<%if row_num == 5 or row_num == 10 or row_num == 15 or row_num == 20 or row_num == 25%>
..show code here
<%endif%>

Obviously this assumes you have 25 records per page (as standard)
Cheers

I know this is an old message, but I've seen this come up a few times, and I know I've done something similar on several of my sites, but I used something like:

Code:
<%ifnot row_num % 5 %>
....show advert code here....
<%endif%>

So, until the remainder is "0" no ad will show. So, every 5th link, 5 % 5 = 0. 10%5=0,. etc will show an ad.
If you make the "5" a global, such as $skip_links, you can set the number of links per page and the number of links to skip from the admin interface, without editing the template again.

Code:
<%ifnot row_num % $skip_links %>
....show advert code here....
<%endif%>


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.