We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38190
    • 15 Posts
    Hello everyone and Happy New Year!
    Just finished my second website (www.jimpatravel.com) done with Modx and getting to love this CMF more an more.
    Now I'm planning to start a new project and I definitely need your help and advises. It's going to be a basic network of Universities/Departments/Students working together on few common projects in the city where I live right now (Xining, China).

    The structure will be something like this:
    -University1
    --Department1
    ---Student1
    ---Student2
    --Department2
    ---Student3

    -University2
    --etc....

    I want Students profiles as Resources because this website has to be bilingual (English and Chinese) and I want each Profile to have some extra fields (richtext, dropdown, image) where each Student can write the status of their own assignment/notes/images and to be accessible to anyone who visits the website.

    How can I create a Resource for each Student (user) and only him/her to be able to edit that resource?
    How can limit the access to this resource so only the Owner has the write to edit it?
    How can I pull some of the info from Profile into Resource?
    Is there a way to automatically create a resource with the above requirements on new user registration/ creation?


    Thanks!
    [ed. note: zoadie last edited this post 12 years, 3 months ago.]
      • 3749
      • 24,544 Posts
      I would strongly advise you not to make resources out of all the profiles. In MODX Revolution, the profiles already exist in the database and you can add extra 'extended' fields to them in the Manager. The Profile snippet will show them, and the UpdateProfile snippet will let users update them in the front end (both are part of the Login package). The Peoples package also has snippets that will show views of selected user profiles.

      If you have the skills, you can also subclass the user object and add any extra fields to a custom user table, which is more efficient and convenient once you get it set up.

      If you make a separate resource for each user, you will be duplicating all the data and carrying all the extra overhead of resources (you have no need for most of the resource fields, but you'll be storing and processing them anyway).

      Worse yet, your resources won't necessarily be synchronized with the user data in the database unless you add that functionality and if you decide to add a new user field or reformat the display, you'll have to edit every resource, so maintenance will be a nightmare.

      One key to good design is to separate the data (model) from the view. You'd be mixing them in the worst possible way. Instead, I'd suggest a single resource (or a small number of them) to display the user data for any user and maybe another one (or again a small number) to allow editing it.

      I hope I don't sound too critical here. I just hate to think of what you'd be facing down the road with that design. 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
        • 38190
        • 15 Posts
        Thanks Bob!
        Don't worry, I like criticism, it's a good way of learning! shocked)
        I've been searching the forums and couldn't find anything similar to what I want. Probably Oleg's Networkit snippet would be the closest, but still not exactly.

        I already had a look at Peoples but doesn't seem to be flexible enough.
        How should I setup the user groups?
        UniversitiesGroup
        -University1Group
        --University1Department1Group
        ---User1
        ---User2 huh

        And how can retrieve only the UniversitiesGroup with PeopleGroups and not include the Administrator and all the others?

        Can I add a richtext TV and image TV to a user profile?

        Thanks!
          • 38190
          • 15 Posts
          And I forgot the most important part...has to be bilingual
            • 4172
            • 5,888 Posts
            I've some ideas how you could do it. But it's not without a bit coding.

            You can create your structure for university/departments with modx-resources.
            I'm working on MIGXdb.
            This is a TV which can list records from db-tables in a grid which can be joined to resources.
            Its possible to edit each record and have TVs like image-TVs and richtext-TVs in the editor-window.
            I can think about a context-menue for the grid 'connect this user to this resource' and a switcher to show all users/only connected users.

            It would be of course also possible to restrict profile-editing only for own profile, but may be its better to let them edit their profile only from frontend.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 38190
              • 15 Posts
              Hi Bruno!
              Thanks for your reply!
              Actually this is exactly what I had in my mind first. To create University/Department/Student structure with resources and different templates.

              And probably I didn't make myself clear what I want to to do with Student resource. Doesn't have to duplicate the User, but extend it with some TVs which can be easily updated only by the User.

              I created a StudentsGroup and I assigned all the students to that Group, I created StudentsProfile resource Group, and I assigned all Student resources to that group and the rest of the resources to Administrator.

              I even managed to show only his own resource when a user loges in setting the tree_root_id to his own resource ID, but the problem is that he can still has access to other's students profile if he types in the browser manager/?a=30&id=y, where Y can be any other resource's ID.

              Is there any way to give permission to one user to edit only one resource?

              ps: guess what, I was planning to use migx. It's an amazing way to combine different TVs in one.
                • 4172
                • 5,888 Posts
                I think I would create only this structure for University/Department/
                but not resources for students.

                you can use the extended-userfield for additionial infos or an extra custom-table joined to the users-table.

                If the students do nothing else than editing their own profile, I would try to do that from frontend, not from modx-manager.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 38190
                  • 15 Posts
                  But if I create the full structure University/Department/Student it will be much easier to list the Students under that specific department.

                  So there is no way to create a User Page?

                    • 3749
                    • 24,544 Posts
                    Keep in mind that TV values are always tied to specific resources, so putting the user-submitted value in a TV (rather than in an extended user field) would get you back to having one resource per student.
                      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
                      • 38190
                      • 15 Posts
                      I'm still searching the forum for details about permissions.
                      The Student has to be a resource because I want it to be more complex than just data pulled from User. I want to create 3 "subpages" with TVs and displayed with tabs for each student: Info, Project Status, Contact (where some of the User details can be displayed).

                      How can I give permission to User1 to edit only Student1 resource?