We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38783
    • 571 Posts
    I am in the process of creating a web site for a dog training club. I am using Bob Ray's wonderful ClassExtender http://bobsguides.com/classextender-class.html to provide additional fields for members data.

    This is working well. However, having entered a lot of data for all the users, I have realised I need an additional field.

    Through trial and error (with, fortunately some backups in place!) I think that the only (and correct?) way to do this is as follows...


    • Use phpMyAdmin or similar to back up the contents of the 'ext_user_data' table to a .sql file.
    • Drop (delete) the 'ext_user_date' table
    • Amend the MyExtUserSchema and MyExtraUserFields chunks to include the new fields
    • Re run Extend modUser to regenerate the 'ext_user_data' table with required fields and update the User interface
    • Use phpMyAdmin or similar to import the user data exported in step one in to the new, empty 'ext_user_data' table. In my case it seemed necessary to comment out the lines in the sql backup file that read ALTER TABLE `ext_user_data` and ADD PRIMARY KEY (`id`);.

    This brings in the old data, correctly associated with the user. However, before I am able to add any data into extended fields I seem to have to re run Extend modUser a second time. I'm not sure if this is correct.

    The above seems to work in the limited test that I have just run. However, it would be really good if someone who knows what they are doing could advise if this is indeed the correct way to go about this, or if I am unwittingly making a right mess of things!

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

      If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

      email: [email protected] | website: https://andytough.com
      • 4172
      • 5,888 Posts
      normally, you just need to modify the xpdo - schema, parse it again and (let) add the new fields to the table.

      This can easylie be done for example with MIGX.
      Within the MIGX - CMP, there is a part, where you just click the Button 'Add Fields' , which would parse the modified schema and add the new fields to your table.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 38783
        • 571 Posts
        Hello Bruno, thank you for the quick response. I think that because I am using ClassExtender modUser that there might be a specific order in which I have to do things. I am using it because I am not knowledgeable enough to modify the xpdo schema myself.

        If I add fields to 'MyExtUserSchema' they are not written to the 'ext_user_data' table if it already exists, which is why I was trying the workflow above.

        But perhaps I am missing something and making the process harder than it needs to be?
          If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

          email: [email protected] | website: https://andytough.com
          • 3749
          • 24,544 Posts
          I haven't really thought about this, but I don't think ClassExtender will modify an existing table (though it's a good feature request). You could export the table data, drop the table, run ClassExtender, and then import the data, but that's probably not the easiest way to do it.

          I believe CE will modify the class and map files for you (and if not, you could just just delete them and run it again).

          If you add the new fields to the table yourself (either before or after creating the new class and map files), you should be fine.

          I'm not sure if Bruno's method will update the existing class and map files, but I suspect it does. In that case it's probably the way to go.

            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
            • 38783
            • 571 Posts
            Hi Bob, Thanks for helping. So just to make sure I have it right, the long winded method I am using is OK,

            but I could more easily do this by...


            • Creating the extra field in the ext_user_data table, using phpMyAdmin or similar
            • Amend the MyExtUserSchema and MyExtraUserFields chunks to include the new field
            • Re run Extend modUser
              If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

              email: [email protected] | website: https://andytough.com
              • 3749
              • 24,544 Posts
              I think so. Just check the class and map files to see if they were updated.
                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
              • discuss.answer
                • 38783
                • 571 Posts
                Hi Bob, I have had a chance to test this out and your suggestion worked. So to clarify, the solution was


                • Creating the extra field in the ext_user_data table, using phpMyAdmin or similar
                • Amend the MyExtUserSchema and MyExtraUserFields chunks to include the new field
                • Re run Extend modUser

                This updated the following files:

                • /core/components/classextender/model/schema/extendeduser.mysql.schema.xml
                • /core/components/classextender/model/extendeduser/mysql/userdata.map.inc.php

                Thank you Bob and Bruno for your help and advice.
                  If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

                  email: [email protected] | website: https://andytough.com
                  • 3749
                  • 24,544 Posts
                  You may also have to update the ExtraUserFields chunk if you want the fields to show in the Create/Edit User form.
                    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