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

    I run a social golf club and i wanted to post events i.e Matches & tournaments on the website.

    Then based on their Web user "Account" have them simply click a button to register to play in that particular event and have them come up in a list on the event page.

    Is this possible with any existing snippet and if not what would you be able to suggest i do?

    Thanks in Advance

    Daniel
      • 25663 MODX Staff
      • 12,272 Posts
      I would honestly look at http://www.eventbrite.com/
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 29774
        • 386 Posts
        Quick and dirty solution - create an ’Event’ template and create a document for each event. Create a TV called ’Attendees’ and attach it to the Event template. The idea is that this TV will contain a comma delimited list of webuser ids.

        Create a snippet called ’AddMeToEvent’ and add to the Event template; something like this:

        <?php
        if ( isset($_REQUEST['addme']) ) {
            // grab the logged in user's id
            $userId = $modx->getLoginUserID();
            // get this document id
            $docId = $modx->getDocumentIdentifier();
           // retrieve the existing value of 'Attendees' for this document
            $attendeesTv = $modx->getTemplateVarOutput('Atendees');
            // explode in to an array of webuser ids
            $attendees = explode(",", $attendeesTv); 
            // add the new user
            array_push($attendees, $userId);
            // convert back to a delimited string
            $attendeesTv = implode(",", $attendees); 
            // do sql queries to update/insert into the modx_site_tmplvar_contentvalues table
            // see cakeModx's setTV() method for an easy way to do this: 
            // http://modxcms.com/forums/index.php?topic=35663.0
        
        }
        
        ?>
        


        The above would be triggered by a link like this [~[*id*]~]?&addme=1

        To output the list of attendees you need another snippet and pass [*Attendees*] to it as a parameter. This snippet would iterate through the list of webuser ids and retrieve each person’s fullname (using eg $modx->getWebUserInfo($userId) - see the wiki), then output it as a list.
          Snippets: GoogleMap | FileDetails | Related Plugin: SSL