We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10357
    • 573 Posts
    Hi,

    is it possible to run a snippet just one time? i am using the RandomImage snippet and i want to have a background image that is site wide but changes the next time you visit the page. So each browsering session it only runs once.


    thanks,
    Gareth
      • 25483
      • 741 Posts
      Can you explain a little bit more what you want?

      Do you want that when a user enters the site the snippet get’s runned and then set’s a variable that will have the same value until the user leaves the website. Therefore you will have to make a snippet that creates a php session.
        with regards,

        Ronald Lokers
        'Front-end developer' @ h2o Media

        • 10357
        • 573 Posts
        yes! that`s right, i want to run the randomImage snippet when the user first visits the site and than have that background image throughout the site.

        i will look into php sessions, sorry i am not very good with php.

        thanks smiley

          • 7231
          • 4,205 Posts
          I agree with MediaGuy, a php snippet using a session var will work throughout the entire site for each visitor. Don’t think anything like this is available so you may need to code something yourself. The good news is that it is not too difficult, may even be possible to modify the randomImage snippet.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 25483
            • 741 Posts
            Yeah, he has to build in a check to see if a session variable is set, if it isn’t set you set it or else you do nothing wink

            Only thing I don’t know is if you have to start a session or if MODx already does this for you?
              with regards,

              Ronald Lokers
              'Front-end developer' @ h2o Media