Context is a pretty powerful feature in the new core. The way I approach contexts is to consider having one instance of the MODx core but being able to run several subsites and subdomains off that single core. Each subsite/subdomain would exist within it’s own context and therefore could have it’s own system settings, cache etc. (but still have access to global settings if required). Contexts can be more subtle than that though, for example, the MODx Manager now sits within it’s own context.
Admittedly, it is difficult grasping some of the new concepts being presented in MODx 0.9.7 because they are all at various stages of implementation - I know I struggled initially wrapping my head round it all.
I’d safely ignore the Wikipedia explanation as that’s describing something totally different (just with the same name).
Hope that helps (rather than confusing you even more),
Garry
Garry Nutting
Senior Developer
MODX, LLC
Email:
[email protected]
Twitter: @garryn
Web: modx.com
-
- 65 Posts
is there a tutorial on setting up a context and what happens internally when you do?
ie: what settings are available for a context, what files are created to support those settings, is there any special API functions related to contexts... as in can I make a plugin to detect a user-agent and then re-direct them to a special context...
Also, do contexts share content or templates or resources? If so, in what way... as in can I share a *page* resource between contexts and update TVs in one place but see the changes in all the contexts that use that resource but have separate contextual templates for the output?
No tutorials yet I’m afraid, but this will be covered. For now, a context is simply a way to segregate configuration and content, in various ways.
All settings are available in contexts; the way MODx requests work, they load the system configuration, then the specified context configuration, overriding any or all of the elements from the system configuration (though overriding all of them is likely never going to be real scenario). Via the API, you will be able to log users in or out of specific contexts (or all of them at once). And you will absolutely be able to use a plugin to detect the user-agent and take appropriate action, or detect language preferences, etc.
Theoretically, you will be able to share a single Resource (i.e. a Page or Document) across multiple Contexts, but the TV values would be the same in all contexts unless they contained logic to detect the context and render different content on that basis.
almost sounds like a context is an object, and you can extend and override the default basic context object, but it will still be able to access everything its parent base object can.