We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1331
    • 129 Posts
    Does anyone have suggestions on the best way to create a system that would automatically give a user group access to certain content when said content reaches x. days of age?

    For instance, I want to give a group access only to blog entries that are OLDER than 30 days. But without having to manually change the resource group of these articles.
      • 7222
      • 20 Posts
      On the face of it, I have a feeling that the way you could use contexts might help here.

      Different getResources calls based on the context it is in? I'm thinking aloud, sorry!
        • 41406 ☆ A M B ☆
        • 30 Posts
        Your best bet would be to utilise a cron job (if your server allows it) - every day at midnight run a script that finds all resources that have a published date of >NOW()-30 and the add the to the relevant resource group.
        .
        If you can't run a from job you could accomplish it with snippets or getResources, but it will add a huge weight onto your page load time as it would have to recalculate on every single page load rather than just once a day
          • 1331
          • 129 Posts
          Quote from: alanpich at May 20, 2013, 05:39 PM
          Your best bet would be to utilise a cron job (if your server allows it) - every day at midnight run a script that finds all resources that have a published date of >NOW()-30 and the add the to the relevant resource group.
          .
          If you can't run a from job you could accomplish it with snippets or getResources, but it will add a huge weight onto your page load time as it would have to recalculate on every single page load rather than just once a day

          That sounds like a viable solution. I'll think through that.
            • 3749
            • 24,544 Posts
            If you can't use a cron job, you could put the code in a plugin attached to something like OnDocFormSave or OnPageNotFound that won't slow the site down too much, or in a snippet with a tag on a page that isn't accessed too often.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting