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

    I want to select an 'employee' for certain resources - and pull in their contact details such as name, email, telephone number etc.

    All employees are already on the site within a Migx call within a different 'staff' page.

    Is there any way I can grab a particular contact from a dropdown of available ones somehow in a TV?

    I'm sure it's possible, but cannot figure it out.

    Thanks!
    Andy

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

    [ed. note: tm2000 last edited this post 6 years, 3 months ago.]
      • 3749
      • 24,544 Posts
      An @SELECT TV might do it:

      @SELECT `username`,`id` FROM `modx_users` WHERE `active` = 1


      I think you'd need a custom snippet to display the user's details on the page, but see if that TV works first.

      [ed. note: BobRay last edited this post 6 years, 3 months ago.]
        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
        • 3749
        • 24,544 Posts
        OK, I tested this, and it works. It uses the Profile snippet (part of the Login package).

        UserTV:

        Type: Listbox (Single-Select)
        Input Option Values: @SELECT `username`,`id` FROM `modx_users` WHERE `active` = 1

        On your page:

        [[!Profile? &user=`[[*UserTV]]`]]
        
        <p>Username: [[+username]]</p>
        <p>FullName: [[+fullname]]</p>
        <p>Email: [[+email]]</p>
        <p>State: [[+state]]</p>
        


        You can use any placeholders from the user or
        user profile object. If you need to use extended fields, do this:

        [[!Profile? &user=`[[*UserTV]]` &useExtended=`1`]]


        The Profile snippet tag must be above all the placeholders.



        [ed. note: BobRay last edited this post 6 years, 3 months ago.]
          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
          • 17301
          • 932 Posts
          That's actually really helpful bob for a project I'm also working on at the moment. Will be sure to donate again for this contribution. Would it be easy to select users from a specific user group rather than all users? I think the original poster may have also had a need for this as he mentioned staff users only.

          Thanks again
            ■ email: [email protected] | ■ website: https://alienbuild.uk

            The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
          • discuss.answer
            • 3749
            • 24,544 Posts
            Thanks. smiley

            I think it's possible, but it's not easy. wink

            I think this is it (where the number at the very end is the ID of the user group):

            @SELECT modx_users.username, modx_users.id FROM modx_users LEFT JOIN modx_member_groups ON modx_users.id = modx_member_groups.member where modx_users.active = 1 AND modx_member_groups.user_group = 4


            I don't have a good way to test it. Let me know if it works.
              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
              • 51020
              • 670 Posts
              Quote from: BobRay at Jan 24, 2018, 10:59 PM
              Thanks. smiley

              I think it's possible, but it's not easy. wink

              I think this is it (where the number at the very end is the ID of the user group):

              @SELECT modx_users.username, modx_users.id FROM modx_users LEFT JOIN modx_member_groups ON modx_users.id = modx_member_groups.member where modx_users.active = 1 AND modx_member_groups.user_group = 4


              I don't have a good way to test it. Let me know if it works.

              Thanks for this - it's really helpful. I will have a go and see if it solves the problem - brilliant.
                • 3749
                • 24,544 Posts
                Don't thank me until it works. wink
                  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
                  • 51020
                  • 670 Posts
                  Quote from: BobRay at Jan 25, 2018, 08:50 PM
                  Don't thank me until it works. wink

                  It always Works Bob!! And I've checked - it's perfect. thank you.
                    • 17301
                    • 932 Posts
                    *donation sent.

                    Thank you, Bob!!
                      ■ email: [email protected] | ■ website: https://alienbuild.uk

                      The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                      • 51020
                      • 670 Posts
                      Quote from: lkfranklin at Jan 26, 2018, 09:16 AM
                      *donation sent.

                      Thank you, Bob!!

                      Where do I donate? I would like to buy a coffee or a beer or three.