We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36632
    • 202 Posts
    I have one of several Revo sites where the getResources Property Sets are not saving.

    It just doesn't "take". I have no idea where to begin troubleshooting since this is just a DB interaction. Right?
      • 3749
      • 24,544 Posts
      Are you sure they're not saving? I recently had a similar problem, but when I looked in the DB, the property set was there and it was used when specified in the snippet tag -- it just didn't show up in the grid when editing the snippet.



      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 29877
        • 35 Posts
        I just experienced this issue myself this morning. I had just created a new set, and saved custom properties to it last Friday. I had been using it for an hour or so, making several changes to the set and clearing the cache every so often as I made changes to the pages where I used the set.

        This morning I came to find my custom properties missing from the set I created on Friday. I added the custom properties to the set again, clicked save. I was given the message "Save successful!" as normal. However, when looking closing the set and re-opening, all of the properties are the defaults.

        I've looked into my database, searching for a unique string used in my custom properties, only to not find it. It appears that in my case, it isn't save correctly. I can't figure out what what be causing this as it worked on Friday and I can't think of anything I changed that would have affected this.

        I will investigate and report back with any information that I may find.
          • 22303 MODX Staff
          • 10,725 Posts
          What version of MODX are you using specifically?
            • 29877
            • 35 Posts
            Quote from: opengeek at Jul 16, 2012, 11:31 AM
            What version of MODX are you using specifically?

            I am using 2.2.4-pl.

            I have investigated my situation a bit further and have corrected the issue, despite not really learning what happened that led up to the problem.

            I will point out that I had previously been revising my property sets by going to the snippet in which I created it for: "Elements" > "Snippets" > "getResources", clicking the "Properties" tab, and then selecting my set ("Summary Page") from the drop-down to the left of the button "Add Property Set". This is where I was NOT seeing my custom properties this morning.

            After my previous email, I remembered the other location in which you can get to the property sets you've already created: "Tools" > "Property Sets". When I clicked on my set "Summary Page", I was only seeing one property listed.

            I "created" the additional properties that I had previously set, saved and checked everything. All seemed to be working again.
              • 36632
              • 202 Posts
              I too thought this was the answer but the Snippet+PropertySet calls didn't function. They didn't display the sortby, limit nor resource properties as specified by the PS.

              My host provided me with this patch (code below) for the
              core/model/modx/processors/element/propertyset/get.php

              This affected 2 of my Revo sites.

              Caveat: I don't know if I'm allowed to share this file with anyone, so use at your own risk!

              <?php
              /**
               * Grabs a property set
               *
               * @package modx
               * @subpackage processors.element.propertyset
               * @var modX $modx
               */
              if (!$modx->hasPermission('view_propertyset')) return $modx->error->failure($modx->lexicon('permission_denied'));
              $modx->lexicon->load('propertyset');
              
              /* if getting properties for an element as well */
              if (!empty($scriptProperties['elementId']) && !empty($scriptProperties['elementType'])) {
                  /** @var modElement $element */
                  $element = $modx->getObject($scriptProperties['elementType'],$scriptProperties['elementId']);
                  if ($element) {
                      $default = $element->get('properties');
                      if (!is_array($default)) $default = array();
                  }
              }
              
              /* if no id specified */
              if (!isset($scriptProperties['id']) || $scriptProperties['id'] == '') {
                  return $modx->error->failure($modx->lexicon('propertyset_err_ns'));
              }
              /* if grabbing a modPropertySet */
              if ($scriptProperties['id'] != 0) {
                  /** @var modPropertySet $set */
                  $set = $modx->getObject('modPropertySet',$scriptProperties['id']);
              
              } elseif (isset($default)) {
                  /* if grabbing default properties for an element */
                  $isDefault = true;
                  $set = $modx->newObject('modPropertySet');
                  $set->set('id',0);
                  $set->set('name',$modx->lexicon('default'));
                  $set->set('properties',$default);
              }
              
              if (empty($set)) {
                  return $modx->error->failure($modx->lexicon('propertyset_err_nfs',array('id' => $scriptProperties['id'])));
              }
              
              
              /* get set properties */
              $properties = $set->get('properties');
              if (!is_array($properties)) $properties = array();
              
              /* first create temporary array to store in */
              $data = array();
              
              /* put in default properties for element */
              if (isset($default)) {
                  foreach ($default as $property) {
                      if (!empty($property['options']) && is_array($property['options'])) {
                          foreach ($property['options'] as &$option) {
                              if (empty($option['text']) && !empty($option['name'])) $option['text'] = $option['name'];
                              $option['text'] = !empty($property['lexicon']) ? $modx->lexicon($option['text']) : $option['text'];
                          }
                      }
              
                      $data[$property['name']] = array(
                          $property['name'],
                          $property['desc'],
                          !empty($property['type']) ? $property['type'] : 'textfield',
                          !empty($property['options']) ? $property['options'] : array(),
                          $property['value'],
                          !empty($property['lexicon']) ? $property['lexicon'] : '',
                          false,
                          $property['desc_trans'],
                          !empty($property['area']) ? $property['area'] : '',
                          !empty($property['area_trans']) ? $property['area_trans'] : '',
                      );
                  }
              }
              
              /* now put in set properties */
              foreach ($properties as $property) {
                  $overridden = false;
                  /* if overridden, set flag */
                  if (isset($data[$property['name']]) && !isset($isDefault)) {
                      $overridden = 1;
                  }
                  /* if completely new value, unique to set */
                  if (!isset($data[$property['name']]) && !empty($scriptProperties['elementId'])) {
                      $overridden = 2;
                  }
              
                  foreach($property['options'] as &$option) {
                      if (empty($option['text']) && !empty($option['name'])) $option['text'] = $option['name'];
                      $option['text'] = !empty($property['lexicon']) ? $modx->lexicon($option['text']) : $option['text'];
                  }
              
                  $data[$property['name']] = array(
                      $property['name'],
                      $property['desc'],
                      !empty($property['type']) ? $property['type'] : 'textfield',
                      !empty($property['options']) ? $property['options'] : array(),
                      $property['value'],
                      !empty($property['lexicon']) ? $property['lexicon'] : '',
                      $overridden,
                      $property['desc_trans'],
                      !empty($property['area']) ? $property['area'] : '',
                      !empty($property['area_trans']) ? $property['area_trans'] : '',
                  );
              }
              
              /* reformat data array for store */
              $props = array();
              foreach ($data as $key => $d) {
                  $props[] = $d;
              }
              $set->set('data','(' . $modx->toJSON($props) . ')');
              
              return $modx->error->success('',$set);
              
                • 3749
                • 24,544 Posts
                I'm curious about where that code came from? Did the host write it or find it somewhere?

                The reason I ask is that this should be submitted at http://bugs.modx.com if it hasn't been already.


                The MODX code is under the GPL license, so it's fine to post any code derived from it.

                The change, BTW, is in this section starting around line 52 (the new part is the "if" statement on line 3 of the new code section below and its matching closing brace on line 8 ):

                Original:

                if (isset($default)) {
                    foreach ($default as $property) {
                        foreach($property['options'] as &$option) {
                            if (empty($option['text']) && !empty($option['name'])) $option['text'] = $option['name'];
                            $option['text'] = !empty($property['lexicon']) ? $modx->lexicon($option['text']) : $option['text'];
                        }
                        
                        $data[$property['name']] = array(
                            $property['name'],
                            $property['desc'],
                            !empty($property['type']) ? $property['type'] : 'textfield',
                            !empty($property['options']) ? $property['options'] : array(),
                            $property['value'],
                            !empty($property['lexicon']) ? $property['lexicon'] : '',
                            false,
                            $property['desc_trans'],
                            !empty($property['area']) ? $property['area'] : '',
                            !empty($property['area_trans']) ? $property['area_trans'] : '',
                        );
                    }
                }


                Changed to:

                if (isset($default)) {
                    foreach ($default as $property) {
                        if (!empty($property['options']) && is_array($property['options'])) {
                            foreach ($property['options'] as &$option) {
                                if (empty($option['text']) && !empty($option['name'])) $option['text'] = $option['name'];
                                $option['text'] = !empty($property['lexicon']) ? $modx->lexicon($option['text']) : $option['text'];
                            }
                        }
                 
                        $data[$property['name']] = array(
                            $property['name'],
                            $property['desc'],
                            !empty($property['type']) ? $property['type'] : 'textfield',
                            !empty($property['options']) ? $property['options'] : array(),
                            $property['value'],
                            !empty($property['lexicon']) ? $property['lexicon'] : '',
                            false,
                            $property['desc_trans'],
                            !empty($property['area']) ? $property['area'] : '',
                            !empty($property['area_trans']) ? $property['area_trans'] : '',
                        );
                    }
                }



                ------------------------------------------------------------------------------------------
                PLEASE, PLEASE specify the version of MODX you are using.
                MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 2 months ago.]
                  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
                  • 10208 ☆ A M B ☆
                  • 1,780 Posts
                  Quote from: BobRay at Jun 14, 2012, 04:38 PM
                  Are you sure they're not saving? I recently had a similar problem, but when I looked in the DB, the property set was there and it was used when specified in the snippet tag -- it just didn't show up in the grid when editing the snippet.

                  This is what's happening right now while trying to set up DefaultResourceGroup (per your advice :~}). So what did you do to make it re-appear? I see it in the drop down and can select it, but it doesn't appear in the grid for editing. It's saved, if I try to re-create it it tells me that it already exists.


                    Frogabog- MODX Websites in Portland Oregon
                    "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                    Having server issues? These guys have MODX Hosting perfected - SkyToaster
                    • 3749
                    • 24,544 Posts
                    I don't remember the details, but I *think* I solved it by working in FF rather than Chrome. It may be a Chrome extension issue.

                    IIRC, I could edit the property set's properties in Tools -> Property Sets.


                    ------------------------------------------------------------------------------------------
                    PLEASE, PLEASE specify the version of MODX you are using.
                    MODX info for everyone: http://bobsguides.com/modx.html
                      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
                      • 10208 ☆ A M B ☆
                      • 1,780 Posts
                      In tools-> property sets it shows up like a container for the existing DefaultResourceGroup plugin. Not editable.
                        Frogabog- MODX Websites in Portland Oregon
                        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                        Having server issues? These guys have MODX Hosting perfected - SkyToaster