We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15003
    • 85 Posts
    Hello

    I am using the Rich Text widget for the [+user.comment+] field, unfortunately it doesn’t save the content entered into the database. If I go to the web users panel in the admin section of modx and save some text I can see the info coming through on the update-profile page, but when I click on save the content in the comments field is lost. Anybody have any suggestions?

    Thanks for any help offered!
    ~Jules
      • 15003
      • 85 Posts
      Thinking that I wasn’t connecting to the database correctly I was decided that instead of placing [+user.comment+] as the default value I need to use the data source binding @SELECT
      http://wiki.modxcms.com/index.php/%40SELECT_Binding

      Unfortunately I’m not sure how to go about writing a functional MySQL statement. Do I need to somehow reference the id of the logged on user? Since I wasn’t sure how to do that I went ahead and figured out how to write a statement to get all comment fields from a table and hoped that somehow it would already know which user ID the form was referring to.

      SELECT `comment` FROM `modx_web_user_attributes`     -- This gets all the comments from table


      The code above worked. I was successfully able to bring in the content entered through the admin panel for "create/edit web user" to the update profile page. BUT when I click on save using the update profile web page the content in the comment field is removed. Note: updated info in all other fields is saved.

      I feel stuck, I can’t think of any other leads to chase down. Why isn’t the rich text field connecting with the database? Anybody got any ideas? Sure would appreciate any help offered.

      Thanks ~Jules
        • 10487 MODX Staff
        • 1,535 Posts
        I’m confused as to where you are using the Rich Text field for the comment field - is this WebLoginPE, ManagerManager or something else?
          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 15003
          • 85 Posts


          I am using the rich text field for the comment <textarea> in WebLoginPE.

          Overview:
          My client wants to be able to leave individual messages and document links for each client he works with. Using the comment field in the admin area he can enter his messages through the Web Users panel. On the users side I have display:none to prevent his clients from being able to edit the comment field in the update-profile page. Using a webloginPE call I placed this comment within each service package page he offers so a customized message will be seen by each client. [+user.comment+] needs to be included in the code of the update-profile form or any information saved through the admin panel is removed, but the regular html <textarea> replaces code characters within the <textarea> field with HTML Entities. I thought that using a Rich Text template variable would resolve this issue, but when save is clicked (on the update profile form) all info in the comment area is removed.

          Thanks so much for your help!
          ~Jules
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            I think you need to make sure you are understanding what the [+placeholders+] are doing. They don’t automatically do anything... they have to be parsed by a specific Snippet, in this case WebLoginPE... but if the Snippet isn’t on the lookout for a particular placeholder, then no value will replace the placeholder.

            To list the comments field of a particular web user, your SQL query would look something like this:
            mysql> select comment from web_user_attributes WHERE internalKey='1';


            The web user id is stored in the "internalKey" column... so the trick is to get the id of the user who’s currently logged in. This is stored in the $_SESSION array... I’m not sure if there’s a short cut to get this value, but you can find it easily enough if you use print_r($_SESSION)..

            Does this make sense?
              • 15003
              • 85 Posts
              @Everett
              Thanks for the clarification.

              Since using the placeholder [+comment+] didn’t seem to work as the default value in the Rich Text template variable I set up to replace the <textare> I thought that maybe I needed to use the data source binding @SELECT --Unfortunately nothing I try seems to work, including the msql statement you suggested.

              I can only see data saved in the comment field from the update-profile page if it was saved from the web user panel in the admin area. Once save is clicked on the update-profile page any text in that field disappears.

              I’m new to modx and am still trying to figure out where the actual problem is.

              Cheers!
              Jules
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                Jules-

                Re my MySQL query -- how did test it? Did you test it on the MySQL command line? You may have prefixes to your table names, but I did test that query and paste it, so I know it worked at least on my mysql install. As the Wiki on the @SELECT binding recommends, test your query in MySQL before bringing MODx into the equation.

                I’m still getting weird vibes from your nomenclature, like maybe you’re trying to do something in the wrong way.

                Can you back up for us? Can you walk us through EXACTLY what you are doing? Step by step? I think that’d be helpful so we can better assessments of what might be going wrong.

                Thanks,
                Everett
                  • 15003
                  • 85 Posts
                  Everett-

                  Thanks for the continued interest. The following MySQL command line does work:
                  SELECT `comment`FROM `modx_web_user_attributes` WHERE internalKey='1'


                  Below are the details of my work

                  Set up a Template Variable
                  Variable Name: comment-RT
                  Description: Template Variabelt to store rich text for Consultant comments to Clients
                  Input Type: RichText
                  Input Option Values: (blank)
                  Default Value: @SELECT `comment`FROM `modx_web_user_attributes` WHERE internalKey=’1’
                  Widget: RichText

                  Selected template allowed to access/process this variable

                  Created Chunk holding form to update profile {{update-profile-form}}
                  [+wlpe.message+]
                  <div id="wlpeUser">
                      <form enctype="multipart/form-data" id="wlpeUserProfileForm" action="[~[*id*]~]" method="post">
                          <fieldset id="wlpeUserProfileInput">
                              <div id="wlpeUserInfo">
                                  <h3 id="wlpeProfileWelcome">Hello [+user.fullname+]!</h3>
                                  <p id="wlpeProfileInfo" class="info">Use this form to update your profile information</p>
                              </div>
                         
                              <legend class="display-none">Your User Profile</legend>
                  
                              <label for="wlpeUserProfileFullName"><span>Full Name</span>
                              <input id="wlpeUserProfileFullName" class="validate[required,custom[onlyLetter],length[0,100]] text-input" type="text" name="fullname" value="[+user.fullname+]" />
                              </label>
                  
                  
                              <label for="wlpeUserProfileEmail"><span>Email</span>
                              <input id="wlpeUserProfileEmail" class="validate[required,custom[email]] text-input" type="text" name="email" value="[+user.email+]" />
                              </label>
                  
                              <label for="wlpeUserProfilePhone"><span>Business number</span>
                              <input id="wlpeUserProfilePhone" class="validate[optional,custom[telephone]] text-input" type="text" name="phone" value="[+user.phone+]" />
                              </label>
                  
                              <label for="wlpeUserProfileMobile"><span>Mobile number</span>
                              <input id="wlpeUserProfileMobile" class="validate[optional,custom[telephone]] text-input" type="text" name="mobilephone" value="[+user.mobilephone+]" />
                              </label>
                  
                              <label for="wlpeUserProfileFax"><span>Fax number</span>
                              <input id="wlpeUserProfileFax" class="validate[optional,custom[telephone]] text-input" type="text" name="fax" value="[+user.fax+]" />
                              </label>
                  
                              <label for="wlpeUserProfileState"><span>State</span>
                              <input id="wlpeUserProfileState" type="text" name="state" value="[+user.state+]" />
                              </label>
                  
                              <label for="wlpeUserProfileZip"><span>Zip Code</span>
                              <input id="wlpeUserProfileZip" type="text" name="zip" value="[+user.zip+]" />
                              </label>           
                  
                                    [*comment-RT*]
                  
                                    <!--Once this actually works I will use css so that the comment field will not be visible/editable to users.-->
                             
                             
                        </fieldset><!-- /wlpeUserProfileInput -->
                         
                          <fieldset id="wlpeUserProfileButtons">
                         
                              <button type="submit" id="wlpeSaveProfileButton" class="submit" name="service" value="saveprofile">Save</button>
                             
                              <!--<button type="submit" id="wlpeProfileDoneButton" class="submit" name="service" value="cancel">Cancel</button> -->
                             
                              <input type="button" id="wlpeProfileDoneButton" class="submit" name="service" value="Cancel" onclick="window.location.href='[~24~]';" />  
                             
                              <button type="submit" id="wlpeProfileLogoutButton" class="submit" name="service" value="logout">Logout</button>   
                                     
                          </fieldset>
                         
                      </form>
                     
                      <button type="button" id="update-pw" class="submit" name="service" value="Update password" onclick="window.location.href='[~16~]';">Update Password</button>        
                  </div><!-- /wlpeUser -->


                  Placed WebloginPE call on update-profile.php page
                  [!WebLoginPE? &type=`profile` &profileTpl=`update-profile-form` &profileHomeID=`24` &disableServices=`deleteprofile,register`!] 


                  Note: I find it confusing that I get the same results using the different Default Value for [*comment-RT*]


                  • blank
                    [+comment+]
                    @SELECT `comment`FROM `modx_web_user_attributes` WHERE internalKey=’1’
                    @SELECT `comment`FROM `modx_web_user_attributes`


                  In all four instances any content that is saved in the admin panel "Create/edit web user" is visible on both the profile and update-profile pages. BUT if the update profile page is saved the content is removed from the database.

                  Thanks again for taking the time to help me:-)
                  ~Jules
                    • 9207 ☆ A M B ☆
                    • 2,475 Posts
                    Thanks for clarifying all of this. This may be a WebLoginPE question... I wrote a bunch of pages on the wiki a few months back:
                    http://wiki.modxcms.com/index.php/WebLoginPE

                    I don’t know if you can mix your various placeholders like that... the template variable stuff [*comment-RT*] may have to live inside your template or content and not in the WebLoginPE chunk... I’m not sure if the parser will see that at the right time.

                    Do this: try putting the [*comment-RT*] inside the content of your document -- leave WebLoginPE out of the equation, and verify that it displays the text that you want it to display. Does the value come out in the document as expected? If not, then you know the problem lies in your template variable configuration. I’m not sure if you want to use the Rich Text widget like that. Did you read up Template Variables? http://wiki.modxcms.com/index.php/Template_Variable Specifically about Widgets.

                    I seem to remember that there was a problem with the WebLoginPE updates somehow. Maybe you should probably post a refined version of your question (using the same detailed info).

                    Sorry... I’m not more specific here. I wrote a lot of those Wiki pages, but it’s been a while, so I don’t remember the exact nuances here.
                      • 15003
                      • 85 Posts
                      I have gone over and over and over the WebLoginPE documentation searching for a way to do this (and TV docs). I started out posting in the WebLoginPE area of the forum, but I just wasn’t getting the feedback I needed to resolve the issue. Then when I thought I would find a solution going in this direction I posted a more specific question here thinking it would work if I could just get the link between the RichText template variable and the database.

                      I did do as you suggested and placed the [*comment-RT*] in it’s own form without a WebLoginPE call on the page and it was NOT binding to the database. So... not sure what to try next here. I think maybe some food and a break might be in order before taxing my brain again:-)

                      I don’t know if you can mix your various placeholders like that... the template variable stuff [*comment-RT*] may have to live inside your template or content and not in the WebLoginPE chunk... I’m not sure if the parser will see that at the right time.
                      I can’t see how [*comment-RT*] could be anywhere but in the update-profile form template (&profileTpl=`update-profile-form`)

                      I didn’t see any WebLoginPE parameters that I could include in the call that would direct the code to use RichText for a specific field. Believe me I looked for that very possibility, any hook that I might exploit. But this is the first site I’ve built using MODx, or any other CMS for that matter, so no doubt there could be much I’m missing just from inexperience.

                      I appreciate your input, thank you.
                      Jules