hi everybody!
I’ve been using a plugin to extend the system settings with your own variables, and I’m looking for feedback on whether that’s a good idea or if there are issues that I haven’t considered.
I’ve come to loathe mixing certain static stuff like ids and member groups into snippet params, phx, etc, as well as wanting to be able to flag things, like turning comments on and off with ease. I haven’t come across anything like this, maybe it’s not a good idea, or perhaps there is another way?
This plugin will add a new tab labeled ’Settings’ that should show up in Tools/Configuration, before the ’File Manager’ tab.
I think this idea makes portability of pages from one site to another much easier as well, so you don’t have to get in and reconfigure things in multiple places.
It seems to work pretty well, but I have just noticed a strange issue... I’m testing on a fresh bare bones install of
MODx 0.9.6.2 with no other plugins, snippets, chunks, tvs, or modules. I created a system setting with a
setting_name of ’mo_money’ =
setting_value ’mo problems’. In the content of my document, I added this...
mo_myvar => [(mo_myvar)]
mo_money => [(mo_money)]
’mo_myvar’ has not been created yet. The only foreign and `mo_` setting that has been created is ’mo_money’. When I run the page, [(mo_myvar)] was being replaced with ’mo problems’, and [(mo_money)] is blank. So the output is...
mo_myvar => mo problems
mo_money =>
Weird. When I create ’mo_myvar’ and set it to ’bad penny’, each setting gets the correct value as expected.
mo_myvar => bad penny
mo_money => mo problems
I have been using this code in a couple sites with about 20 settings each and I haven’t had any issues. I don’t have any extraneous tags though either. I would have thought tags without a value would simply be removed, but it seems to be replacing incorrect instances. I’ve played a little more and when I test it seems like it replaces the first match it considers ’close enough’. Very bizarre. Any ideas? Once all tags actually map to a setting, everything works as expected.
The day I go to post about it, clean it up a bit and test it, I see this weird issue come up!
Anyway, code is attached... all feedback is appreciated!
Updated to force setting names to lowercase, as required by system_settings convention.