We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26320
    • 4 Posts
    Hi, I am new here and still slowing finding my way around using Modx.

    We want to create a hunt where people create a log in to access a private area (have achieved this part). We then want to them to locate a icon on another site and when they click that icon, it brings them back to us and registers it they have located it. Can this be done and how could I do it?

    I have little programming skills and what little I can do is all self taught so please go easy on me!
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      I’m not sure I understand what you’re trying to do... can you clarify what you mean by a "hunt"?

      If you’re having people click icons on another site... is this other site something you control? Or is it any random site? If it’s a site you control, you may be able to send data from site B back to site A, but it’s not easy. If it’s any random site, I don’t see any realistic way of you accomplishing this. Maybe you can explain more what you mean...
        • 26320
        • 4 Posts
        A hunt like a treasure hunt involving several sites. We ask sites to hide a button/icon somewhere within their site. A hunter comes along to locate it, they find it, click on it. It brings them back to our site and somehow records that user found that button/icon. They more onto the next one. and so on. At the end of it, we (admin) can see how many icons each user found.

        I know it is possible to do but I am not sure how it is done.
          • 3749
          • 24,544 Posts
          It’s very easy enough to have images point to a page on your site, but keeping track of the hunters is a challenge.

          One way to do it is to capture the user’s IP number and save it. Then the link on the other site would look like this:

          <a href="URL of your page?site_id=1234"><img src="path to image"></a>


          Where each of the remote sites has a unique ID. On the page at your site, you’d capture the IP again, check the site_id argument and give that hunter credit for the find. You’d want your own custom database table with the hunter’s IDs, names, and site_ids they’ve successfully found the token on. You could have a field for each site_id, or put them all in one field, separated by commas -- adding the new find each time they come back to your site if it’s not there already.

          It’s not all that complicated, but the many users with dynamic IPs would have to do the whole hunt in one session. A better alternative might be to save a cookie on the user’s machine and use that to ID the users on return visits. If they clear cookies or have them turned off, though, they’re out of luck.

          It would be pretty easy for people to cheat if the site_ids become public (and they’ll be visible to all users in the URL back to your site). They could get credit for the finds without visiting the other sites at all just by entering the right URLs. If that’s an issue, the only totally reliable way to do it is to have the user sign in with a username and password on each site they visit and have code that validates them through your site before sending them back, but that’s probably not practical. It could probably be done without them signing in using JavaScript on each site, but the other sites would all have to install the script in addition to adding the link.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting