We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 813 ☆ A M B ☆
    • 326 Posts
    I think this will involve a custom TV, but just throwing it out there in case anyone else has an idea (or better yet, an existing solution):

    I want to display a list of staff members (set up as MODX users) on an "Our People" page. Currently, I'm using the Peoples snippet to do this. However, I'd like my site managers to be able to determine the sort order of the staff members via a TV on the "Our People" page, ideally with drag-and-drop.

    Any suggestions?
      • 3749
      • 24,544 Posts
      I think a regular drop-down list TV would do it with this in the Peoples tag:

      &sortBy=`[[*TvName]]`
        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
        • 813 ☆ A M B ☆
        • 326 Posts
        Thanks, Bob. Just to make sure I'm following:


        1. I've already written a utility snippet that grabs all of my users in a particular group and outputs them as fullname==id, for use in TVs
        2. In my TV, I call @EVAL return $modx->runSnippet('getUsers'); in Input Option Values
        3. I I make the TV a Listbox (Multi-Select)
        4. I set the sortBy in Peoples to this TV, as you suggested

        Sound right? Seems like it will work to me, but just documenting, in case anyone else has this need.

        Thanks!
          • 813 ☆ A M B ☆
          • 326 Posts
          New issue -- I don't think I can sort peoples by a TV; only by a user field. Docs here:

          http://rtfm.modx.com/display/ADDON/Peoples.Peoples

          Other ideas?
            • 38290
            • 712 Posts
            Neither of these stick to the wall well but
            - user setting used as a menu index like field
            - use resources or MIGX instead of just a snippet call

            If users don't need their own pages of course prob want to shy away from using resources to represent them.
              jpdevries
              • 3749
              • 24,544 Posts
              I confess that I now have no idea what you're trying to do. wink

              If Peoples is displaying the list of users, why would you need a list of users in the TV?

              I was assuming that the TV would have something like this to specify the sort field:

              username||fullname||email


                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
                • 813 ☆ A M B ☆
                • 326 Posts
                Haha -- sorry to confuse.

                The TV is just to make it easier for the site manager to set the sort order of the users as they're displayed on the front end. Peoples is still doing the display; I just want the site manager to be able to control that order via a TV.

                I think JP is on the right track with using MIGX -- I'd just add each person as a MIGX item, and then they can just drag-and-drop. It's not quite as clean as a sort TV, but I guess it will get the job done, unless you have another idea.
                  • 3749
                  • 24,544 Posts
                  Right, but in order to set the sort order, why would the site manager need to see a list of users? Couldn't he or she just select the field to sort by?

                  If you need to sort by an extended field, it shouldn't be too difficult to modify the Peoples snippet to do that with a getCollectionGraph() call instead of getCollection() -- I could be wrong.
                    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
                    • 813 ☆ A M B ☆
                    • 326 Posts
                    They need to see the users because I want the sort to be based on an arbitrary arrangement of the users, set by the site manager. For example, let's say I have three users:

                    1. Aaron Ladage
                    2. Bob Ray
                    3. JP DeVries

                    Those can easily be sorted alphabetically. However, let's say you're the president of the company, JP is vice president, and I'm the janitor (no offense to janitors). I want the site manager to be able to reorder the list like this:

                    1. Bob Ray
                    2. JP DeVries
                    3. Aaron Ladage

                    That sorting needs to be managed in a single place (I don't want them to have to set an arbitrary sort value on each user). A TV makes the most sense for this, but MIGX is probably as close as I can get without a custom TV input type.

                    Also, just to clarify: I'm using Peoples right now, but I'm perfectly okay with rolling my own users collection snippet. I just thought there might be a really simple way to do this out of the box that I hadn't thought of.
                      • 3749
                      • 24,544 Posts
                      Ah, I get it now and I see where the drag-and-drop would come in, but I can't think how to implement the UI part of it. For the execution part, you could create a "menuindex" extended field. Maybe you could steal the code used to display resources by menuindex in the tree.
                        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