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
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.]
both, edit system-settings or chunks, should be possible with a MIGXdb-grid-TV
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
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
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.]
I'll give that a go... thanks!
I LOVE MODX! | greyskymedia.com
-
☆ 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.
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
-
☆ 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)