We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Try changing this:

    [[!SetResourcePlaceholders]]
    

    to this:

    [[!SetUserPlaceholders]]
      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
      • 46886
      • 1,154 Posts
      The only ones it currently doesn't show though are the ClassExtender (which are just the arrival and departure dates), how can I add those ClassExtenders ones to the profile page to display or be updated on the "Manage profile" page too.

      I think you need a snippet to call the ClassExtender db and get the data, but when I was looking for the answer I came upon a great resource from Andy, scroll down to the part about profiles.

      https://andytough.com/assets/files/modx-meetup_adido_bournemouth_06-07-2017_andy-tough.pdf

      A taste
      Displaying member profiles
      using getUrlParam
      Send members idCode to the page that will display their profile
      <a href="[[~106? &val=`[[+idCode]]`]]">
      ie: https://modx.andytough.com/profileview?val=R07D-07Z
      Display their details on that page using GetExtUsers having
      captured their idCode value using getUrlParam
        • 46886
        • 1,154 Posts
        The only ones it currently doesn't show though are the ClassExtender (which are just the arrival and departure dates), how can I add those ClassExtenders ones to the profile page to display or be updated on the "Manage profile" page too.

        I think you need a snippet to call the ClassExtender db and get the data, but when I was looking for the answer I came upon a great resource from Andy, scroll down to the part about profiles.

        https://andytough.com/assets/files/modx-meetup_adido_bournemouth_06-07-2017_andy-tough.pdf

        A taste
        Displaying member profiles
        using getUrlParam
        Send members idCode to the page that will display their profile
        <a href="[[~106? &val=`[[+idCode]]`]]">
        ie: https://modx.andytough.com/profileview?val=R07D-07Z
        Display their details on that page using GetExtUsers having
        captured their idCode value using getUrlParam

        The whole thing looks documented. Its brilliant! [ed. note: nuan88 last edited this post 5 years, 9 months ago.]
          • 36426
          • 197 Posts
          Quote from: nuan88 at Jul 07, 2018, 07:12 PM
          The only ones it currently doesn't show though are the ClassExtender (which are just the arrival and departure dates), how can I add those ClassExtenders ones to the profile page to display or be updated on the "Manage profile" page too.

          I think you need a snippet to call the ClassExtender db and get the data, but when I was looking for the answer I came upon a great resource from Andy, scroll down to the part about profiles.

          https://andytough.com/assets/files/modx-meetup_adido_bournemouth_06-07-2017_andy-tough.pdf

          A taste
          Displaying member profiles
          using getUrlParam
          Send members idCode to the page that will display their profile
          <a href="[[~106? &val=`[[+idCode]]`]]">
          ie: https://modx.andytough.com/profileview?val=R07D-07Z
          Display their details on that page using GetExtUsers having
          captured their idCode value using getUrlParam

          The whole thing looks documented. Its brilliant!</a>

          Hi thanks that is brilliant! It has helped me also clean up my current code and add in the existing user validation and non-active user removal too!

          I've ran into another problem now. When I add data into a field in the modx user manager and click save, although it says it has saved, when I click out and back into that user there is no data saved in the new fields! This may be why they aren't displaying on the profile page too - for some reason they're not saving.

          this is MyExtraUserSchema:

          <?xml version="1.0" encoding="UTF-8"?>
          <model package="extendeduser" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="ext_" version="1.0.0">
              <!-- extend the modUser class -->
              <object class="extUser" extends="modUser">
                  <composite alias="Data" local="id" class="userData" foreign="userdata_id" cardinality="one" owner="local"/>
              </object>
              <object class="userData" table="user_data" extends="xPDOSimpleObject">
                  <field key="userdata_id" dbtype="int" precision="11" phptype="integer" null="false" attributes="unsigned"/>
                  <field key="checkin" dbtype="date" precision="100" phptype="date" null="true"/>
                  <field key="checkout" dbtype="date" precision="100" phptype="date" null="true"/>
                  <field key="registrationDate" dbtype="datetime" phptype="datetime"/>
          
                  <index alias="userdata_id" name="userdata_id" primary="false" unique="true" type="BTREE">
                      <column key="userdata_id" length="" collation="A" null="false"/>
                  </index>
                  <aggregate alias="User" class= "modUser" local="userdata_id" foreign="id" cardinality="one" owner="foreign"/>
                  <aggregate alias="Profile" class="modUserProfile" local="userdata_id" foreign="internalKey" cardinality="one" owner="foreign"/>
              </object>
          </model>


          and here is MyExtraUserFields:

          <div class="x-form-item x-tab-item">
              <label class="x-form-item-label" style="width:auto; font-weight:bold; float:none; font-size:12px">Arrival Date (dd/mm/yyyy)</label>
          
              <div class="x-form-item x-tab-item">
                  <input type="text" name="checkin" value="[[+checkin:strtotime:date=`%d/%m/%Y`]]" class="x-form-text x-form-field"
                          onClick="Ext.getCmp('modx-panel-user').markDirty();"/>
              </div>
          </div>
          
          
          <div class="x-form-item x-tab-item">
              <label class="x-form-item-label" style="width:auto; font-weight:bold; float:none; font-size:12px">Departure Date (dd/mm/yyyy)</label>
          
              <div class="x-form-item x-tab-item">
                  <input type="text" name="checkout" value="[[+checkout:strtotime:date=`%d/%m/%Y`]]" class="x-form-text x-form-field"
                          onClick="Ext.getCmp('modx-panel-user').markDirty();"/>
              </div>
          </div>


          I've also viewed the extModUser resource and clicked submit too...

          I've tried creating users in the manager and registering from the frontend, but both won't save and store the extra fields. Any help would be great to get this finally working smiley
            Yorkshire UK based hosting provider: https://www.simulant.uk
            • 36426
            • 197 Posts
            Hi further to this I tried manually dropping the mysql table. Then though when I run the extend mod user resource to create it again it gives this error:

            createObjectContainer() failed

            So I tried manually creating the table (ditching the registrationDate column and just having checkin, checkout and the userdata_id). Then when I ran extend mod user resource again and click submit it works ok.

            After then saving the checkindate and checkoutdate in the manager, again they just show blank when you navigate back to them. But when I check in phpmyadmin it IS saving the date in the ext_user_data table.

            So maybe I haven't created the table properly so I've dropped it again for now just until anyone here can help further.

            So in summary it does save, but modx doesn't pull the data back to either the manager or frontend... and I can't create the table from the extend mod user resource either.
              Yorkshire UK based hosting provider: https://www.simulant.uk
              • 3749
              • 24,544 Posts
              Did you change the snippet to this? And is the snippet above the placeholders?

              [[!SetUserPlaceholders]]
                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
                • 36426
                • 197 Posts
                Quote from: BobRay at Jul 08, 2018, 08:49 PM
                Did you change the snippet to this? And is the snippet above the placeholders?

                [[!SetUserPlaceholders]]

                Hi thanks Bob - yes I have already updated to this as you suggested, but I still can't save or pull those fields which is strange. How can I go about Diagnosing this further?

                I've tried updating existing user profiles from the backend/manager and the fields don't save, so I also created a few test "new" users but again those won't save either. The fields show, I can add the data to them. I click save and then the boxes still have the correct data in them so it appears to work.

                I then check phpmyadmin and see that the ext_user_data table has the field data and things look good!

                However! When I go back to the modx manager, click off the user and click back on to their profile again I can see those fields are again empty.

                AND on their profile page the data isn't displayed still either.

                I also still have the issue that when I delete the table row and try make it fresh again from the moduser resource page, it gives me that "createObjectContainer() failed" error. So possibly the problem is with this and how I'm then manually making the row in phpmyadmin?

                  Yorkshire UK based hosting provider: https://www.simulant.uk
                  • 38783
                  • 571 Posts
                  If the data is being written to the correct field in the database, but is not displaying in the Manager I suspect there may be a problem with the text in your MyExtraUserFields chunk.

                  I have not got time to check at the moment (I'm popping out for a while) but I am not sure if the following is valid for this chunk...

                  [[+checkin:strtotime:date=`%d/%m/%Y`]]


                  I think you would use [[+checkin]] in your MyExtraUserFields chunk and then use [[+checkin:strtotime:date=`%d/%m/%Y`]] when displaying the date in the front end.

                  Bob will know though. I may be completely wrong here.

                  As a matter of interest what version of MODX are you using? I encountered the error createObjectContainer() failed when seeing if I could install ClassExtender in the alpha of version 3, 'MODX 3.0.0-dev'. [ed. note: andytough last edited this post 5 years, 9 months ago.]
                    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
                    Bob has no idea. wink

                    There's this: https://bobsguides.com/blog.html/2013/09/18/displaying-modx-date-fields/. But I'm not sure how that all affects date fields in ClassExtender when they're shown in the Manager.

                    In the DB are you seeing human-readable dates or just a large number?

                    It occurs to me that ClassExtender may be using str_replace() to replace the placeholders. If that's true, using output modifiers would lead to no output.

                    Do you get any output if you leave off the output modifier?

                    FWIW, the snippets and plugins in CE are sort of "suggestions" to get you started with the class. They were never meant to do everything you might want, and I suspect that date fields might require some extra code in the snippet.
                      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
                      • 36426
                      • 197 Posts
                      Quote from: andytough at Jul 16, 2018, 04:34 PM
                      If the data is being written to the correct field in the database, but is not displaying in the Manager I suspect there may be a problem with the text in your MyExtraUserFields chunk.

                      I have not got time to check at the moment (I'm popping out for a while) but I am not sure if the following is valid for this chunk...

                      [[+checkin:strtotime:date=`%d/%m/%Y`]]


                      I think you would use [[+checkin]] in your MyExtraUserFields chunk and then use [[+checkin:strtotime:date=`%d/%m/%Y`]] when displaying the date in the front end.

                      Bob will know though. I may be completely wrong here.

                      As a matter of interest what version of MODX are you using? I encountered the error createObjectContainer() failed when seeing if I could install ClassExtender in the alpha of version 3, 'MODX 3.0.0-dev'.

                      Hi thanks. I've switched it around to how I had it so now my MyExtraUserFields chunk has [[+checkin]] as follows:

                      <div class="x-form-item x-tab-item">
                          <label class="x-form-item-label" style="width:auto; font-weight:bold; float:none; font-size:12px">Arrival Date (dd/mm/yyyy)</label>
                      
                          <div class="x-form-item x-tab-item">
                              <input type="text" name="checkin" value="[[+checkin]]" class="x-form-text x-form-field"
                                      onClick="Ext.getCmp('modx-panel-user').markDirty();"/>
                          </div>
                      </div>
                      
                      
                      <div class="x-form-item x-tab-item">
                          <label class="x-form-item-label" style="width:auto; font-weight:bold; float:none; font-size:12px">Departure Date (dd/mm/yyyy)</label>
                      
                          <div class="x-form-item x-tab-item">
                              <input type="text" name="checkout" value="[[+checkout]]" class="x-form-text x-form-field"
                                      onClick="Ext.getCmp('modx-panel-user').markDirty();"/>
                          </div>
                      </div>
                      


                      and my user profile frontend page has [[+checkin:strtotime:date=`%d/%m/%Y`]] like this:

                      [[!Profile]]
                      [[!SetUserPlaceholders]]
                      <h4>Details for user [[+username]]</h4>
                      <p>Email: [[+email]]</p>
                      <p>Full Name: [[+fullname]]</p>
                      <p>Phone: [[+phone]]</p>
                      <p>Mobile: [[+mobilephone]]</p>
                      <p>Website: [[+website]]</p>
                      <p>Address: [[+address]]</p>
                      <p>Address: [[+address2]]</p>
                      <p>City: [[+city]]</p>
                      <p>Postal Code: [[+zip]]</p>
                      <p>Country: [[+country]]</p>
                      <p>Arrival Date: [[+checkin:strtotime:date=`%d/%m/%Y`]]</p>
                      <p>Departure Date: [[+checkout:strtotime:date=`%d/%m/%Y`]]</p>
                      <p> </p>
                      <hr />
                      <p><small>Please visit <a data-ajax="false" href="[[~60]]" title="Customer Portal" >Update Profile</a> area if you wish to amend your details.</small></p>
                      


                      But it hasn't made any difference and still doesn't show the entered date from the Manager "Users" section either in the backend (after refresh) or on the frontend profile page...

                      Here is MyExtUserSchema too in case something is wrong here that may be causing this:

                      <?xml version="1.0" encoding="UTF-8"?>
                      <model package="extendeduser" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="ext_" version="1.0.0">
                          <!-- extend the modUser class -->
                          <object class="extUser" extends="modUser">
                              <composite alias="Data" local="id" class="userData" foreign="userdata_id" cardinality="one" owner="local"/>
                          </object>
                          <object class="userData" table="user_data" extends="xPDOSimpleObject">
                              <field key="userdata_id" dbtype="int" precision="11" phptype="integer" null="false" attributes="unsigned"/>
                              <field key="checkin" dbtype="date" precision="100" phptype="date" null="true"/>
                              <field key="checkout" dbtype="date" precision="100" phptype="date" null="true"/>
                      
                              <index alias="userdata_id" name="userdata_id" primary="false" unique="true" type="BTREE">
                                  <column key="userdata_id" length="" collation="A" null="false"/>
                              </index>
                              <aggregate alias="User" class= "modUser" local="userdata_id" foreign="id" cardinality="one" owner="foreign"/>
                              <aggregate alias="Profile" class="modUserProfile" local="userdata_id" foreign="internalKey" cardinality="one" owner="foreign"/>
                          </object>
                      </model>
                      
                        Yorkshire UK based hosting provider: https://www.simulant.uk