Announcement

Collapse
No announcement yet.

Random Image when new page opens ...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Thanks Kermy

    Is there no way of automating this as there seems a lot of work each time I want to add different images.

    I use tradedoubler and commission junction for the main ads and all I have to do is select the banners I want and they auto load. Appreciate there is a lot that goes on behind the scenes with them but I have one script about 4 lines long on my site for each one.

    Ideally the only update I would need to do would be to say how many banners I have. Is there any software you could recommend that would allow me to manage this?

    Steven

    Comment


      #17
      Steven

      This lets you maintain everything without tinkering with the JavaScript.

      Here's an idea where you can keep up to 10 images in Custom Properties.
      Use Advanced / Custom Properties to create Properties IMAGE1, IMAGE2, ... IMAGE10
      and also properties LINK1, LINK2, ... LINK10.
      Now you maintain the list of images (in Design / Options / Site Defaults)
      and check File Name" and Actinic will upload and maintain changes for you.
      You can also put a list of links e.g. "http://news.bbc.co.uk" into the LINK Customvars.
      You can use all 10 or leave some empty.
      The script will adapt to the number of images you use.

      Put the following just above the </HEAD> tag
      Code:
      <script language=JavaScript>
      var cvimages=new Array('CUSTOMVAR:IMAGE1','CUSTOMVAR:IMAGE2','CUSTOMVAR:IMAGE3','CUSTOMVAR:IMAGE4','CUSTOMVAR:IMAGE5',
                           'CUSTOMVAR:IMAGE6','CUSTOMVAR:IMAGE7','CUSTOMVAR:IMAGE8','CUSTOMVAR:IMAGE9','CUSTOMVAR:IMAGE10');
      var cvlinks=new Array('CUSTOMVAR:LINK1','CUSTOMVAR:LINK2','CUSTOMVAR:LINK3','CUSTOMVAR:LINK4','CUSTOMVAR:LINK5',
                           'CUSTOMVAR:LINK6','CUSTOMVAR:LINK7','CUSTOMVAR:LINK8','CUSTOMVAR:LINK9','CUSTOMVAR:LINK10');
      var images=new Array();
      var links=new Array();
      for (var i=0; i < cvimages.length; i++) { if (cvimages[i] != '') { images.push(cvimages[i]); links.push(cvlinks[i]); } }
      idx = Math.floor(Math.random()*images.length - 0.01);
      showlink = (links[idx] != '');
      </script>
      and put this wherever you want the image to display.
      Code:
      <script language=JavaScript>
      <!--
      if (showlink) document.write('<a href="' + links[idx] + '">');
      document.write('<img border=0 src="' + images[idx] + '">');
      if (showlink) document.write('<\a>');
      //-->
      </script>
      You can also have a different set of images and links for each page by setting these in the Section Properties.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #18
        Don't know whether this helps Steven, but we use a program called Ad Butler to control the banners on our site.

        We have a combination of our own banners and Tradedoubler affiliate banners. Ad Butler costs from around £3.50 a month, but goes up depending on impressions served (normally costs us about £10p/m).

        I seem to remember it being a bit awkward to get going initially, but now it just gets on with it - all I do is update my banner pools with Tradedoubler and rarely need to log into Ad Butler.

        Comment


          #19
          Hi Norman

          Thanks for your code. I have put it in but dont get a banner to appear, and when I mouse over where it should be there is nothing there.

          I have created two images and two links, and have ticked 'Use as customvar' and 'File Name'. On top of that I have checked that the images are in my Site1 folder and also my additional files and all is good.

          Any thoughts on why its not showing. Link to home page is www.xxxx.com

          Thanks

          Steven

          Comment


            #20
            Try replacing this line
            Code:
            for (var i=0; i < cvimages.length; i++) { if (cvimages[i] <> '') { images.push(cvimages[i]); links.push(cvlinks[i]; } }
            with this one

            Code:
            for (var i=0; i < cvimages.length; i++) { if (cvimages[i] != '') { images.push(cvimages[i]); links.push(cvlinks[i]; } }
            Just a syntax error I noticed.
            www.gbradley.co.uk
            Web Development, Actinic Patches, Scripts & more

            Comment


              #21
              Hi

              No, still not there. Checked the source code and that looks ok, snippet is

              <!--
              var cvimages=new Array('fdjad1.gif','fdjad2.gif','','','',
              '','','','','');
              var cvlinks=new Array('http://www.subvertcentral.com/','http://www.knowledgemag.co.uk/allcrews/','','','',
              '','','','','');

              I remember the original problem I had when I put the image on the home page was that I had to do ... acatalog/fdjad1.gif rather than just fdjad1.gif

              I'll try adding that into the customvar within Site Default.

              No, that just confuses the upload and says duplicate products.

              Steven

              Comment


                #22
                Graham: Thanks for pointing out the syntax error. I must have been thinking in another language when I typed that. I've corrected it in the post above.

                Steven: You should only need the "acatalog/" prefix on Brochure home page. For other Brochure pages and the shop pages it should be omitted.

                You may also find it useful to look at these pages using Firefox and turn it's Tools / JavaScript Console on.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #23
                  Steven: Just used Firefox on your home page and discovered another typo in the code I posted at #17 above. I've corrected that now, so copy / paste it and try an Update.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #24
                    Hi Norman

                    Almost there. Theres a placeholder to show that an image should be there but the actual image does not appear. If you mouse over the placeholder then the link is there too.

                    Steven

                    Comment


                      #25
                      Yay! At least the JavaScript is working. Now the error is that you're not in the acatalog directory and haven't got acatalog/ in front of your image names.

                      If you want to use this code throughout the site, the simplest way would be to manually ftp an extra copy of these images to your site root. You'd have to remember to redo this if you change these images.
                      Norman - www.drillpine.biz
                      Edinburgh, U K / Bitez, Turkey

                      Comment


                        #26
                        Wait a minute. Ignore the immediately above post. Are you sure you've ticked the File Name option against these images CUSTOMVARS's? If you do this, Actinic automatically adds in the acatalog/ prefix on the Brochure home page and the code should start working on any page.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #27
                          Hi

                          Yes, File Name is ticked.

                          As a thought, I have created a new subsection with the images in there as products and uploaded. They show fine on that page, but still not showing up in the home page.

                          Steven

                          Comment


                            #28
                            Ahah! I see it now. Actinic (for some unfathonable reason) won't add the acatalog/ prefix if the JavaScript has HTML hiding comments (as all good code within the BODY area should have). The quick fix is to remove the <!-- and the //--> from within the JavaScript. The longer fix is to move most of the JavaScript to the HEAD area. I'll amend the full post of the code above (#17) to fix that.
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment


                              #29
                              Norman

                              Perfect, that seems to do the trick.

                              Images appear and the link works.

                              Thanks for the help

                              Steven

                              Comment


                                #30
                                Hi All,

                                I was wondering if the code you used could be modified to work with individual text files, the thoery is that our websites current homepage contains a collection of 6 images (with attached links), and then a some text under each image.
                                The idea would be to created a collection of text files called product(x).txt, containing the relevant html code to display all the information our homepage uses and then input these files at random.
                                My javascript is very basic (learning as i go), and have been looking at your code, the obvious change would be this method would only require the one array, and then the document.write function would be changed to match.

                                Any ideas?

                                Many thanks
                                Pete

                                E-Commerce Manager, Sales Manager, Admin Manager, Website Maintenance & Designer, and last but no means least Tea Boy!

                                Portsmouth Sound & Light
                                http://www.discosuperstore.co.uk/
                                www.discoSuperstore.co.uk
                                Portsmouth Sound & Light. The South's No.1 DJ Store

                                Comment

                                Working...
                                X