Gossamer Forum
Skip to Content



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.com

Merry Xmas and a Happy New Year!


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!
Custom Toolbar for IE and Firefox! - 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.com

Merry Xmas and a Happy New Year!


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!
Custom Toolbar for IE and Firefox! - 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.com

Merry Xmas and a Happy New Year!


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!
Custom Toolbar for IE and Firefox! - 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.com

Merry Xmas and a Happy New Year!


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!
Custom Toolbar for IE and Firefox! - Compare our different Plugin packages *new*
Free CSS Templates

Last edited by:

Andy: May 12, 2008, 1:39 AM