We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17895
    • 209 Posts
    Hi everyone,
    I have a website splitted in multiple contexts (one for each language). I have two (related) problems:
    1) I have the CSS files as resources, is it possible to make it accessible from EVERY contexts? Otherwise I have to replicate them for each context.
    2) There are some "hidden" resources (e.g., AJAX responders) that are not related to the language context. Is it possible to have a "hidden" context and, again, make it possible to access to these resources from the other contexts?

    Thanks!
      Daniele "MadMage" Calisi
      • 26016
      • 561 Posts
      Hi,
      I don’t know if you can share resources across contexts, let’s see what others say. But you can certainly share CSS across contexts if it’s in the file system, as opposed to being a resource in the database. This way I don’t have to have so much CSS code around.

      You can have it both ways, too... I like to have some shared CSS across contexts, but have some overrides for each context, even if they share the same template. Sort of like the concept of child themes in Wordpress. Very centralized, and less code to write.
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 17895
        • 209 Posts
        Quote from: samba at May 04, 2011, 03:40 PM

        Hi,
        I don’t know if you can share resources across contexts, let’s see what others say. But you can certainly share CSS across contexts if it’s in the file system, as opposed to being a resource in the database. This way I don’t have to have so much CSS code around.

        You can have it both ways, too... I like to have some shared CSS across contexts, but have some overrides for each context, even if they share the same template. Sort of like the concept of child themes in Wordpress. Very centralized, and less code to write.

        Hi Samba, thanks for the answer.

        Actually I am going to use some meta-language for CSS (e.g., SASS, LESS or whatever), so I would like to have them as resources (automatically parsed by the SASS or LESS converter). Moreover, in this way I have only one access point to edit the website content (being them templates, CSS, convent, whatever).

        Of course the problem remains with "hidden-context" resources (e.g., AJAX responders). Is there any tutorial for the contexts, in particular for what happend with the presentation layer (rather than the manager)? I can only see two examples in the documentation, but it’s not clear, for me, why I should "switch" a context in order to see other context’s resources.
          Daniele "MadMage" Calisi
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          You could make a 3rd (or 4th, 5th depending on how many you have already) context "resources" or "assets", set a unique entrance url (eg assets.domain.com) and put your CSS, JS, connector resources etc in there. Could even attempt to make that subdomain cookieless.

          You can "hide" it from the regular admin user using access control lists.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.