We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8274 ☆ A M B ☆
    • 222 Posts
    I am trying to add a couple custom form fields (combo boxes) to the General Info tab of a user profile page. These would list what grade the user teaches, and what subject they specialize in.

    Each field adds a new classification parameter to the user for organizing in the front end (a directory of employees). The values of the combo boxes are static (similar to Country combo box), and a user can only belong to a single item in each combo box, and these settings are stored in a custom database (because there could be more custom settings for a user in the near future).

    Would writing a plugin that inserts these ExtJs/ModExt form widgets into the General Info page (OnUserFormPrerender) be the best way? Or am I approaching this poorly?

    Using ExtendedFields seemed like a poor choice because the key-value pairs need to be consistent across all users.

    Before I spend much longer on this, I wanted a quick sanity check.
      • 33968
      • 863 Posts
      You might try writing a plugin although that's going to be a bit tricky to slot the widget into the right place. Otherwise it might be better to create a new 'Teacher Info' CMP that's tailored exactly to the kind of data you need to set up.

      You can borrow heavily on the existing 'Add User' JS and processor code to accomplish this...
        • 3749
        • 24,544 Posts
        Your approach sounds fine, but an alternative would be to just create resource with a snippet for a front-end form and have it only function when previewed from the Manager.


        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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
          • 9102 ☆ A M B ☆
          • 318 Posts
          Bob and Lucas, since the idea here is to have all of the user info in one place, do you think this might be a case where it would make sense to extend modUser and override the manager controllers to make actual custom create and update pages?
            • 4172
            • 5,888 Posts
            I think I would extend modUser and create a CMP (with help of MIGXdb) to manage all extended Users.
            This seems easier and more flexible to me, than overriding the existing manager-controllers.

            To get comboboxes into MIGXdb - driven CMPs you can define a listbox-TV with input-options as usual or for example dynamicDropdown-TVs to any Custom-table-fields.
            Also adding searchbox or combobox-filters is easy done with MIGXdb - CMPs
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 9102 ☆ A M B ☆
              • 318 Posts
              Perhaps it would be more flexible to create a CMP, but is that the user interface you want? I think it boils down to that, really. There are lots of ways to do this, and the question is how do you want it to look to manager users. If you want "teachers" to look just like normal users except that they have a couple of extra fields, you could override the normal manager controllers for users. If you want them to be on a separate page and managed differently from other users, you would create a CMP or a front-end page like Bob suggested. If you don't think it's worth the trouble of actually extending modUser, you could just use a plugin -- what you're losing there is the explicit connection between the extended user class and your custom DB tables, but maybe you don't really need that.
                • 3749
                • 24,544 Posts
                On second thought,, it's fairly easy to use a plugin connected to OnUserFormRender and OnUserFormSave to insert extra fields into the user form and store them as extended user fields on save or update. There's an example in my book (p. 492).

                I think that's what I'd do unless you will have a whole lot of users or you need high speed when retrieving the information. In those cases, I'd recommend Bruno17's suggestion about extending modUser (although that can complicate things somewhat in other parts of the site and in code that deals with users).


                ------------------------------------------------------------------------------------------
                PLEASE, PLEASE specify the version of MODX you are using.
                MODX info for everyone: http://bobsguides.com/modx.html
                  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
                  • 8274 ☆ A M B ☆
                  • 222 Posts
                  These are all the things I was looking forward to considering. (BobRay, your reference to your book is what started this whole process for me... *lightbulb*).

                  As for manager teachers, the interface would need to have fields to edit modUser data, as well as custom user data in a single screen. So my first thought was that it would be easiest to extend the UserCreate/UserUpdate panels. But as pointed out, this could have impacts on other parts of the site.

                  If I created a CMP, I would be pulling ModUser data fields anyway which on the surface seems redundant if this type of interface already exists. BUT I am just not very aware of the data access needs/differences between a CMP and extending ModUser.

                  I know currently all the teachers are represented by a Resource (http://www.oakhilldayschool.org/school-directory.html), but I am not happy at all with that solution as my Resource tree is out of control with pages.

                  I will give the extend ModUser + MIGXdb a swing this afternoon, then give the Plugin approach a try to see which fills my need (and can be packaged up for other sites I work on).

                  BTW: The live site is currently running Revo 2.2.0, but i am developing this EmployeeDirectory 2.0 in Revo 2.2.2
                    • 3749
                    • 24,544 Posts
                    That sounds like a good way to go. If you're still considering using extended fields in the profile and doing editing in the front-end, check out the UpdateProfile snippet in the Login package. It would probably mean much faster and easier development.

                    You can pretty easily fix it so it will only work when previewing the page from the Manager, or limit use to members of the Administrator group.

                    You could also give users the option of updating their own profiles without letting them into the Manager.



                    ------------------------------------------------------------------------------------------
                    PLEASE, PLEASE specify the version of MODX you are using.
                    MODX info for everyone: http://bobsguides.com/modx.html
                      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