We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40949
    • 20 Posts
    Hey guys, I've got a bit of a problem.
    I'm in the process of modifying modTemplate to include not only template content for desktop, but also mobile and tablet in separate textareas.

    That's the part that is working, but now I also need to set '_mobileContent' and '_tabletContent' just as '_content' is set in the cache. So I need to add these fields to the cache somewhere to be able to set them in the process function of modResource. I could hack the core files, but that's not how I wanna do this.

    How about it MODx'ers, ya got some info in them there brains that can help me along?
      • 22303 MODX Staff
      • 10,725 Posts
      You might consider setting these as namespaced properties of the Resource, which will get cached. However, modifying modTemplate is still a problem, since there is no facility to override this class at the moment. You would potentially destroy your upgrade path.

      I would consider another approach, using a Snippet as your Template. This snippet can control all it's own custom caching per whatever conditions you are using to determine which content to serve, and dynamically select the actual content to use for the Template. I believe this would be a more upgrade-friendly approach to what you are attempting to do.
        • 40949
        • 20 Posts
        I'll look into this. I hope that with this method it is still possible to get the correct template HTML.

        Because essentially I'm splitting a Template in 3 parts, under one template name. And maybe I've used the wrong words in my explanation, but I wanna serve a mobile device other HTML from Template 'Jackson' then a desktop device gets. And if that can be achieved with a snippet, loaded into an (empty) temlate, well then I'm a happy camper smiley

        I'll see if I can get that method to work