Jump to content


Photo

Rotating adverts from different Affiliate Sites


  • Please log in to reply
13 replies to this topic

#1 oatssi46

oatssi46
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 September 2006 - 06:48 PM

Hi,

I use 3 different affiliate sites, CJ, Affiliate Window and Trade Doubler.  I want to rotate banners from a file using javascript coding from all 3 affiliate sites.  Ideally I would arrange the files by the size of banner.  Does anyone have any ideas as to how this can be done?

Thanks in advance.

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 24 September 2006 - 10:12 PM

probably be easier in PHP, but javascript can load and get the size of an image. Sorting is beyond what I've done in javascript before -- but I'm sure javascript has a way.

img = new Image();
img.src = "path/to/file.jpg";
var size = img.width*img.height


#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 September 2006 - 04:07 AM

I'm not sure I understand whaty ou mean by "arrange the files".
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 oatssi46

oatssi46
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 27 September 2006 - 06:23 PM

Apologies.  I should have been a bit clearer with my post.

By arranging the files, I meant grouping the banners in a file in terms of size.  E.g. one file containg banners of size 125x125, another file grouping banners 60x125 etc.


An example of what I have is below.  I would like to take the example (placed in a separate file) and display one of the banners on the php page where I have used the includes function.  I need some javascript that will randomly select one of the banners and display it accordingly:


<scrpt language="javascript">
var uri = 'http://impgb.tradedo...106094/1287396?' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript language="JavaScript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
</scrpt>

<scrpt language="JavaScript" src="http://www.awin1.com...noscrpt><iframe src="http://www.awin1.com...1&target=blank" width=468 height=60 frameborder=0 border=0 scrolling=no marginheight=0 marginwidth=0></iframe></noscrpt>

<scrpt type="text/javascript" language="javascript" src="http://www.kqzyfj.co...ver=N"></scrpt>

Any help is much appreciated.  Many thanks.



#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 27 September 2006 - 06:59 PM

I'm sorry, I still don't understand... group in a file?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#6 oatssi46

oatssi46
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 28 September 2006 - 08:35 AM

The coding above are the output codes from the different affiliate sites.  I don't think there is too much of an emphasis in where I say group in a file.  I simply mean I will have different files for different size banners. 

The code above is an example of what I would like to place and randomly rotate in a file.  However, I need some code that will randomly rotate the scripts?

Thanks

#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 September 2006 - 03:01 PM

I'm still unclear -- each file has a single banner?  You so have a set of files of the same size, and you want a JS function to swap these images?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#8 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 28 September 2006 - 03:07 PM

I think he's got a javascript with an external source-file. That external script inserts an image when loaded. He's trying to get the image dimensions of the image that the external javascript is presenting.

If I got it right -- it would be cumbersome, if not impossible to get it done.

#9 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 September 2006 - 06:34 PM

There are semi-cumbersome ways to do this, if need be, but I'm not sure why.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#10 oatssi46

oatssi46
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 28 September 2006 - 08:54 PM

Ok, i'll try to make this a bit clearer - sorry you have not understood me as yet! 

Lets say I have one file which I call with the includes function.  Forget about size.  It contains 3 different adverts from 3 different affiliate sites:

"<scrpt language="javascript">
var uri = 'http://impgb.tradedo...106094/1287396?' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript language="JavaScript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
</scrpt>

<scrpt language="JavaScript" src="http://www.awin1.com...noscrpt><iframe src="http://www.awin1.com...1&target=blank" width=468 height=60 frameborder=0 border=0 scrolling=no marginheight=0 marginwidth=0></iframe></noscrpt>

<scrpt type="text/javascript" language="javascript" src="http://www.kqzyfj.co...ver=N"></scrpt>
"

I want to randomly select one of the above adverts to display on the page where I have the includes function.  Any ideas?

I hope i'm making myself clear, my terminology isn't brilliant.

Many thanks.

#11 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 29 September 2006 - 02:58 AM

So you only want to incorporate the resulting image from ONE of these script blocks?  I'm not sure what these produce.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#12 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 29 September 2006 - 03:18 AM

If I had this to do, I'd stuff all the different scripts into a PHP array and use array_rand() to use one at random.

You could also do it with a javascript array and document.write a randomly selected script.

#13 oatssi46

oatssi46
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 29 September 2006 - 03:20 PM

So you only want to incorporate the resulting image from ONE of these script blocks?  I'm not sure what these produce.


Yep thats right.  It would produce an ad banner such as what can be seen at the bottom of the following page:

http://www.paddockgo...com/newsletter/

Maybe a javascript array would work best as michael suggested?


#14 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 29 September 2006 - 05:19 PM

That's probably the best way to handle it, since otherwise you'd have to put all 3 somewhere and them pick one to show, which is rather ugly.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users