We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7231
    • 4,205 Posts
    I have been trying to learn what a context is and how it relates to development (and specifically to MODx). However I have not found any ’for dummies’ type literature to get me started. Can anyone point me in the right direction huh

    Wikipedia’s definition left me with more questions than answers:
    In computer science, a task context (process, thread ...) is the minimal set of data used by this task that must be saved to allow a task interruption at a given date, and a continuation of this task at the point it has been interrupted and at an arbitrary future date. The concept of context assumes significance in the case of interruptible tasks, wherein upon being interrupted the processer saves the context and proceeds to serve the Interrupt service routine. Thus the smaller the context the smaller is the latency.

    I have read this from the roadmap, but I am still not sure:
    Contexts – This new concept will allow MODx configuration settings to be overridden, extended, isolated, or shared across domains, sub-domains, sub-sites, multi-sites, cultural-specific sections, specific web applications, etc.

    I also read the "Transforming MODx: Tales of OO, MVC, and O/RM" article that mentions 1. CONTEXTS: FLEXIBLE FRONT CONTROLLERS and still not clear about the big picture of Contexts.
      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

      Something is happening here, but you don't know what it is.
      Do you, Mr. Jones? - [bob dylan]
    • 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
        • 9941
        • 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.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 7231
              • 4,205 Posts
              Quote from: sottwell at Feb 18, 2008, 06:15 PM

              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.
              This is what I am understanding as well. I guess it will all make more sense once we start messing around with contexts. In other words I need to see it in context shocked
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don't know what it is.
                Do you, Mr. Jones? - [bob dylan]