We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20546
    • 74 Posts
    I had read it in the "extend moduser" tutorial and I thought it would be necessary. Is it enough to just add the package like this?

    $this->modx->addPackage('extendeduser', $this->extPath .'model/', 'ut_');


    And change the users class_key to ’extUser’ for every user that should have access to the custom secured table?
      • 22303 MODX Staff
      • 10,725 Posts
      Hmm, I didn’t write the tutorial; I’ll have to review it, but all you need to do is add your custom package location containing your extended modUser class implementation to the extension_packages system setting. Then make sure to set the class key field properly when adding your "extended" user accounts.
        • 20546
        • 74 Posts
        Great, it works! Thank you so much.

        There comes up another question…
        Is it possible to extend every modx database table like in the "extending modUser" tutorial?

        <?xml version="1.0" encoding="UTF-8"?>
        <model package="extendeduser" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="ext_">
            <!-- inherit the modx user and extend it -->
            <object class="extUser" table="users" extends="modUser">
                <composite alias="Phones" local="id" foreign="user" cardinality="many" owner="local" />
                <composite alias="Table2" local="id" foreign="user" cardinality="many" owner="local" />
            </object>
         
            <!-- track all user phone numbers -->
            <object table="phone_numbers" extends="xPDOSimpleObject">
                <field key="user" dbtype="int" phptype="integer" null="false" default="0" index="index" />
                <field key="areacode" dbtype="varchar" precision="3" phptype="string" null="false" default="" />
                <field key="number" dbtype="varchar" precision="7" phptype="string" null="false" default="" />
                <aggregate alias="extUser" local="user" foreign="id" cardinality="one" owner="foreign" />
            </object>
         
            <!-- user extension -->
            <object table="table2" extends="xPDOSimpleObject">
                <field key="user" dbtype="int" phptype="integer" null="false" default="0" index="index" />
                <field key="myspaceurl" dbtype="varchar" precision="255" phptype="string" null="false" />        
                <aggregate alias="extUser" local="user" foreign="id" cardinality="one" owner="foreign" />
            </object>
        </model>
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: mt85 at Mar 17, 2011, 04:05 AM

          There comes up another question…
          Is it possible to extend every modx database table like in the "extending modUser" tutorial?
          Not yet, but the basics are in place for us to get there. Right now, modResource and modUser are the only MODX classes we have facilities for overriding in place, as far as being supported in the core/manager interface. That being said, if you wanted to create your own management interface, you can technically extend the modX class itself and/or many of the other classes there, I just wouldn’t recommend it until we get a little further along in the roadmap towards content versioning and workflow. wink
            • 20546
            • 74 Posts
            Ok, I’ll wait for this to come…

            Meanwhile I try to start learning how to create components with modExt. I hope there are some nice tutorials out there… smiley
              • 16681
              • 62 Posts
              @mt85 Could you perhaps write a little post on your project and how it worked out? I bet a lot of people would love it! Include yours truly wink

              Ciao
                Keep it SIMPLX
                • 20546
                • 74 Posts
                @larscwallin: It’s actually not a real project. It’s just to get more familiar with the modx core. I’m trying to learn the different parts of modx like CMP, modExt (what’s quite difficult to learn for me since I can’t find good tutorials to start learning it from scratch). The user extension was a start to learn such things, but I think because it’s out of context, it’s not really interesting for other people. However, in future I would really like to offer to write some modx tutorials. But first I have to learn some more things to make sense to write them. First, I also have to improve my english... wink