modmore / ClientConfig

ClientConfig is a MODX Revolution Extra to allow clients to maintain settings in a user friendly way.
https://docs.modmore.com/en/Open_Source/ClientConfig/index.html
MIT License
28 stars 27 forks source link

Make current context available as placeholder in field options #166

Open azeller opened 5 years ago

azeller commented 5 years ago

Summary

This issue only concerns multi-context-mode. This is more of an enhancement than a bug. In some fields it's possible to make snippet calls so tags get processed and you can for example create your own set up input options by calling pdoResources to populate them. This is not context-aware.

Step to reproduce

Try to find a context placeholder and fail at it.

Observed behavior

Me not finding the context placeholder :)

Expected behavior

Me having a [[+clientconfig.context]] placeholder of some sort, so I can do this:

[[pdoResources? 
   &tpl=`@INLINE [[+pagetitle]]==[[+id]]`
   &parents=`0`
   &limit=`0`
   &context=`[[+clientconfig.context:default=`web`]]`
   &outputSeparator=`||`
   &showHidden=`1`
]]

Environment

ClientConfig 2.1.0, MODX 2.7.1, Debian, MySQL 5.7.25, PHP 7.0.33

Mark-H commented 4 years ago

This would likely need to be added in core/components/clientconfig/controllers/home.class.php around line 44-48. Perhaps simply $this->modx->setPlaceholder('context', $context) where $context is a validated key (currently handled around line 57-68.

Would be a cool enhancement but don't have time to build (and more importantly) test that right now.