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

    I'm looking for something for the following.

    Currently I am working on a fitness website, where users have to be able to log-in and see what lessons there are in some kind of list or agenda. If they want to join a lesson they attend to the "lesson" and they get an reminder by email. In the dashboard the sport instructor is able to see who is joining a lesson on a specific day.

    Has anyone some suggestions for this kind of need? I've looked at mxCalendar and ExerPlan, but it's not suitable.

    Looking forward to some thoughts.

    Cheers,
    Ilja

    This question has been answered by BobRay. See the first response.

      • 3749
      • 24,544 Posts
      I can't think of any way to do that without some custom PHP code. You could make a lesson list with links that contained a lesson ID or name in the query string of the URL. Then on the landing page, a snippet could email the user and notify the instructor -- either by email or by putting the users info in a custom database table. In the second case the dashboard could show the instructor who would be attending.

      Maybe someone else has a better idea.
        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
        • 42042
        • 140 Posts
        Thanks Bob. I was thinking something similar. My php skills are OK but I am quite new to costum manipulations in ModX, do you have a good starting point?

        Any other thoughts?

        Cheers,
        Ilja
          • 3749
          • 24,544 Posts
          There's not much to it. You just put a snippet tag like the following on the page and put the PHP code in a snippet with that name. The tag is replaced by the return value of the snippet, and if you don't want anything there, you just return ''.

          [[!SnippetName]]


          If you need to send information to the snippet you add a question mark and parameters preceded by & and with the value in back-ticks:

          [[!SnippetName? &property1=`value1` &property2=`value2`]]


          Then in the snippet:

          $prop1 = $modx->getOption('property1', $scriptProperties, 'defaultValue');
          $prop2 = $modx->getOption('property2', $scriptProperties, 'defaultValue');
          



          The $scriptProperties array always contains all the properties as an associative array. The default value is only set if the property is not sent in the tag.





            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
            • 42042
            • 140 Posts
            Quote from: BobRay at Aug 20, 2014, 06:28 PM

            The $scriptProperties array always contains all the properties as an associative array. The default value is only set if the property is not sent in the tag.

            The snippet calls I knew but, this explanation was new for me, thanks. What I really meant was a starting point on how to use the modx API to use and manipulate the database plus how I can display data in the manager.

            Thanks for your help.

            Ilja
            • discuss.answer
              • 3749
              • 24,544 Posts
              There's a lot of information about using the API to communicate with the DB here: http://bobsguides.com/revolution-objects.html.

              You'll have to be more specific about what you mean by "display data in the manager."

                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
                • 42042
                • 140 Posts
                Ah great, this is helpful. What I mean is the following. I probably have to create a form where people can attend to a lesson. These lessons can come from an XML or the database. The people who attend to the lesson, have to be listed somewhere in the manager so the instructor can see who is coming. So I guess, I have to create some kind of environment where that data shows up.

                Thanks in advance bob, I appreciate it.

                Ilja
                  • 3749
                  • 24,544 Posts
                  How you approach that depends on whether they need to see this information in the Manager (after logging in), or in the front end. Most people like to keep users out of the Manager if possible.

                  As for the data, you can put it anywhere you want. In a custom table in the MODX database, in a file, in a chunk, etc.

                  If you're in the front end, you retrieve the data you want to display by using a snippet tag where you want to show it. The snippet tag will be replaced by whatever string the snippet returns. Often, people use a TPL chunk with placeholder tags:

                  [[+placeholderName]]


                  Then, in the snippet, you create an associative array of placeholder names and values and call $modx->getChunk():

                  $fields = array(
                     'placeholder1' => $p1_value,
                     'placeholder2' => $p2_value,
                  );
                  
                  return $modx->getChunk('MyTplChunk', $fields);
                  


                  The returned result will be the content of the chunk with all the placeholders replaced with the values in the $fields array.

                  If you're in the Manager, it's a little more complicated. You'd have to use a Custom Manager Page (CMP), or MIGX.

                    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
                    • 42042
                    • 140 Posts
                    Thanks for the help Bob. I go try some!


                    Ilja