We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26435
    • 1,193 Posts
    This is an auto-generated support/comment thread for RandomAd.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Selects a random image/link combination from a specified folder
      Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
      All of the above... in no specific order.


      I send pointless little messages
      • 21136
      • 103 Posts
      I like the script smiley

      Is it possible to have it display random images but link to the same URL (page)?

      Or is there another script I should look at?
        • 26435
        • 1,193 Posts
        Quote from: nekstrebor at Nov 06, 2006, 01:25 PM

        I like the script smiley

        Is it possible to have it display random images but link to the same URL (page)?

        Or is there another script I should look at?
        Yes!

        Change line 50 in the snippet code:
        echo "<a href=index.php?id=$imageid>";

        to:
        echo '<a href="http://www.anysite.url/anypage.html">;


        let me know if that works for you.

        -sD-
          Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
          All of the above... in no specific order.


          I send pointless little messages
          • 21136
          • 103 Posts
          COOL!!

          Will give it try.

          Thanks smiley

          Ken
            • 26435
            • 1,193 Posts
            Sorry... I made a typo,

            Change line 50 in the snippet code:
            echo "<a href=index.php?id=$imageid>";

            to:
            echo '<a href="http://www.anysite.url/anypage.html">';


            I forgot a single quote at the end between > and ;
            copy the code from this post instead.

            -sD-
              Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
              All of the above... in no specific order.


              I send pointless little messages
              • 6726
              • 7,075 Posts
              Thanks for the alternate code Scotty, actually didn’t have a chance to test it out yet, but this snippet sure will be handy smiley
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 21136
                • 103 Posts
                Thanks - got it to work smiley

                Since this is a link it is showing up with a border around the image. I was playing around with line 51 to see if I could use border="0". Can you tell me where it should go? I’m making it crash smiley

                echo( "<div class=\"randomAd\"><img src=\"" . $image_name . "\" alt =\"" . $image_id . "\" />
                \n" );

                Regards,

                Ken
                  • 26435
                  • 1,193 Posts
                  much easier than futzing with the snippet code!

                  just put:
                  a img{ border:none; }

                  in your CSS file.

                  -sD-
                    Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                    All of the above... in no specific order.


                    I send pointless little messages
                    • 21136
                    • 103 Posts
                    I went back to the original script and I had to use the bare bones snippet so I could get the script to work. It only works using [!RandonAd!]

                    Can it work with friendly URL’s ?

                    I tried to using...

                    [!RandomAd? &folder=’assets/images/software’!]
                    [!RandomAd? &folder=’/assets/images/software’!]

                    and even [!RandomAd? &folder=’assets/images/random’!]

                    Nothing worked except [!RandonAd!]. Could this be a problems because of using friendly URL’s?

                    Here is the error I get when I try anything but [!RandonAd!] :

                    « MODx Parse Error »
                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »

                    PHP error debug
                    Error: opendir(’assets/images/random’): failed to open dir: No such file or directory
                    Error type/ Nr.: Warning - 2
                    File: /..../manager/includes/document.parser.class.inc.php(705) : eval()’d code
                    Line: 30

                    Parser timing
                    MySQL: 0.0019 s s (3 Requests)
                    PHP: 0.0503 s s
                    Total: 0.0522 s s

                    How can I get it to work with friendly URL’s?

                    Regards,

                    Ken smiley
                      • 26435
                      • 1,193 Posts
                      hmmm...
                      I put this snippet together from part of another snippet (I don’t remember which one) a while ago to fit a particular niche on one of my templates where I wanted a PNG image to pop up on top the header image, linking to a random area of my site. That being said, it is an incredibly simple, somewhat static snippet, i.e. not too versatile.

                      You might want to try :
                      [!RandomAd? &folder='[(site_url)]assets/images/software'!]


                      "[(site_url)]" is one of the built in’s from MODx that gets replaced by the document parser as the actual URL of your site.

                      let me know if it works. BTW, did that CSS work for you?

                      -sD-
                        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                        All of the above... in no specific order.


                        I send pointless little messages