We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40462
    • 9 Posts
    Overview of my project:

    I need to build a profile-based site for a client and already built their current website in ModX. So rather than trying for something custom, I thought "Wouldn't it be cool... (famous last words) ...if I could just use the current ModX site and extend to this profile-based microsite". The existing site is currently on Revo 2.2.5.

    To further separate roles, I'm breaking up the roles into contexts and will assign them to subdomain.

    The site has a few Components (Can also refer to the attached jpg):

    1. User List [in existing web context]: Just needs to display users from a specific usergroup (profile). Available to general public.
    2. Personal Profile [new profile context]: User signs up enters/saves their profile information (mostly text input fields, nothing crazy yet). Must login to update their profile and display it in Component #1.
    3. Reviewer [new review context: Can view a list of summarized user profiles entered by Component #2, and select an individual profile to view the details of.

    Resources so far I've identified I may need:

    So for some Questions...

    1. How can I add custom fields to the user profile? (I'm assuming Extended Fields under user profile, but not finding much documentation yet for actually adding Extended Fields, or is this added as the user is created?)
    2. If using Extended Fields, if I want to link this with automatic registration/user creation, can it automatically set up these fields for a new user upon automatic registration, could you provide an example of the snippet call with extended field (youtube link for example)?
    3. Can I use getResources to publish a list of summarized users (to accomplish the above #1 & #3 Components), if not, what would be a good direction to look into?
    4. Right now, I need to have approximately 20 additional fields/extended fields. Are there any performance issues with as this number grows? (Expecting between 20-50 total)

    If I can get this worked out, hopefully some of this reference information will be useful to someone else in the future.
      • 3186 ☆ A M B ☆
      • 279 Posts
      If you're going to use the Login component, it will handle the extended fields automatically for you. All fields that are not one of the modx_users or modx_user_attributes table will be set to extended fields. You can also add as many you want. With the Login snippets you can also use a parameter to exclude from extended fields, which you don't want to save for example.

      If you just want to save and show that extended fields then using this method is fine. When you need to do some advanced searching I suggest to extend modUser with your own and create an own database table to store the data you want to store for each user. I did this a couple times and it is great working like that. If you do it this way you can build advanced queries, but also do things like $user->getOne('YourObjectThing'); or fill your own "extUser" model with own methods, for example: $user->myOwnValidationStuff();

      Another option is to create just an sort of component, without extending modUser, but I dislike that... I love the way to extend modUser smiley

      Read about that over here;
      http://rtfm.modx.com/display/revolution20/Extending+modUser

      The first time it was difficult to get it working, but now it's like baking eggs smiley
        MODX Ambassador (NL) & Professional MODX developer
        Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
        MODX e-commerce solution SimpleCart
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Hm. I've never baked eggs. Will have to try it sometime.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 3186 ☆ A M B ☆
          • 279 Posts
          Quote from: sottwell at Dec 13, 2012, 09:17 AM
          Hm. I've never baked eggs. Will have to try it sometime.

          Haha! Mark needs to implement a "Like" button :p
            MODX Ambassador (NL) & Professional MODX developer
            Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
            MODX e-commerce solution SimpleCart
            • 40462
            • 9 Posts
            So login/extended fields can handle the storing of the data no problem and displaying it, at least for the individual profile user.

            But if I want to perform queries to generate a list of results, I'll have to extend the modUser?



            Offtopic:
            Quiche!
              • 3186 ☆ A M B ☆
              • 279 Posts
              I prefer extending modUser, because the extended fields of MODX core is just one big text field and the extra fields are stored as a JSON object. If you just want to store and display additional data, it's perfect! For example; I often have "firstname" and "lastname" in my projects.. These fields are not default, so this will be stored as JSON object in extended-fields field, as in {"firstname":"Bert","lastname":"Oost"}... With Login.Profile this fields will be available as placeholders too.. so; store and display would work perfectly!

              But I also creates more difficult sites, with 4/5/6 additional, own tables, with extra fields and I perform searches on it, like locations, ages, genders, favorite items etc. etc. Then it would be better to store the data in own fields so you can perform (bigger) queries on it which will run faster then searchin inside a bunch of text.. In my opinion.

              So based on what you need, you should decide what to do I think.
                MODX Ambassador (NL) & Professional MODX developer
                Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
                MODX e-commerce solution SimpleCart
                • 40462
                • 9 Posts
                Makes sense, but if I want an admin to be able to change that information from within ModX manager, how are extended fields presented for that ModX user? (Will ModX present extended fields as additional text fields when updating that user under Security > Users, or just be available to modUser and my calls?

                ModX makes making CMS-enabled websites a breeze and this project is the first I'm considering for a more application oriented approach.
                  • 3186 ☆ A M B ☆
                  • 279 Posts
                  The core extended fields for users are listed by editting a user below the "Extended fields" tab.

                  When you extend modUser to add your own fields in custom tables, you should make own manager pages OR maybe there is a posibility to add an own tab to the user-edit form? I don't know for sure.. I create own manager pages for that mostly.
                    MODX Ambassador (NL) & Professional MODX developer
                    Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
                    MODX e-commerce solution SimpleCart
                    • 40462
                    • 9 Posts
                    Is there additional documentation on adding manager pages somewhere? So far have only really found: http://rtfm.modx.com/display/revolution20/Custom+Manager+Pages+Tutorial
                      • 3186 ☆ A M B ☆
                      • 279 Posts
                      No you should do it like any other normal component, no difference in there
                        MODX Ambassador (NL) & Professional MODX developer
                        Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
                        MODX e-commerce solution SimpleCart