We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37246
    • 128 Posts
    Grey Sky Media Reply #1, 14 years ago
    I want to create a couple new system settings and have them be editable from a new tab created via form customization.

    The idea is, it would be great to have the ability to edit a few constants from whatever page you're at. Say, you have a phone number, sure, you could use a tv, but that would just change the value on that one page. chunk-> same idea... actually, getting chunk's into a tab would give me the same effect that I'm looking for.

    If anyone knows or can lead me in the right direction i would really appreciate it.

    Thanks!

      I LOVE MODX! | greyskymedia.com
      • 3749
      • 24,544 Posts
      I don't think I'd use Form Customization. You could just create TVs for them and use a plugin connected to OnDocFormSave to update the SystemSettings. Something like this:

      <?php
      $tvValue = $resource->getTVValue('TvName');
      
      $systemSetting = $modx->getObject('modSystemSetting', array('key' => 'settingName'));
      
      if (! empty ($tvValue)) {
          if ($systemSetting->get('value') != $tvValue) {
              $systemSetting->set('value', $tvValue);
              $systemSetting->save();
          }
      } 


      (Change tvName and settingName to the actual names of the objects)



      ------------------------------------------------------------------------------------------
      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 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
        • 4172
        • 5,888 Posts
        both, edit system-settings or chunks, should be possible with a MIGXdb-grid-TV
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 37246
          • 128 Posts
          Grey Sky Media Reply #4, 14 years ago
          Thanks Bob... i'm giving that a go now.

          Bruno, getting my head around MIGx is the next thing for me to learn... i'll give that a go if bob's solution doesn't work for me though
            I LOVE MODX! | greyskymedia.com
            • 37246
            • 128 Posts
            Grey Sky Media Reply #5, 14 years ago
            Bob, i was able to get it to work, except, naturally, it's acting like a TV, since it is. I need the value to pull through to all pages. Does that make sense?
              I LOVE MODX! | greyskymedia.com
              • 3749
              • 24,544 Posts
              If I'm understanding you, the plugin above should set the system setting when you save the resource, but when you need the value, you need to reference the system setting, not the TV. That should be available everywhere.

              But . . . If that TV is attached to other Resources, it may get reset when you save them. I think this would prevent that:

              if (! empty ($tvValue)) {
                  if ($systemSetting->get('value') != $tvValue) {
                      $systemSetting->set('value', $tvValue);
                      $systemSetting->save();
                  }
              }






              ------------------------------------------------------------------------------------------
              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 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
                • 37246
                • 128 Posts
                Grey Sky Media Reply #7, 14 years ago
                I'll give that a go... thanks!
                  I LOVE MODX! | greyskymedia.com
                  • 3109 ☆ A M B ☆
                  • 894 Posts
                  Just change the resources to use the system setting instead of the TV name, for example

                  
                   <p>Phone: [[++system_setting_name]] </p>
                  
                  


                  Instead of:

                  
                   <p>Phone: [[*tv_name]] </p>
                  
                  


                  Remember every time you update system settings you need to clear the cache.
                    Benjamin Marte
                    Interactive Media Developer
                    Follow Me on Twitter | Visit my site | Learn MODX
                    • 37246
                    • 128 Posts
                    Grey Sky Media Reply #9, 14 years ago
                    Thanks Ben, that's not the goal though. I want the client to be able to edit system setting on a resource page
                      I LOVE MODX! | greyskymedia.com
                      • 3109 ☆ A M B ☆
                      • 894 Posts
                      You can still have the client update the TVs and have the TVs update the system settings, the key is to use the system settings in your site instead of the TVs.

                      The Tvs will only work on the page you want the client to edit and they update the system setting you will be using throughout the site.

                      This will work if you use Bobs method (2nd response)
                        Benjamin Marte
                        Interactive Media Developer
                        Follow Me on Twitter | Visit my site | Learn MODX