We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20135
    • 188 Posts
    I've got a site set up using multiple contexts that are accessed via different subdomains. I needed to copy a context and the pages that had been created in that context to a new context, but in doing so, all of the resources were recreated as unpublished, hence they lost their publishedon dates which getResources was using to order its lists. Also, because all of the aliases and URIs being duplicated, MODx starts throwing errors when clearing the cache. Static Resources were hardest hit, with all the aliases being messed up meaning that 600 Static Resources each linking to a PDF were broken, and the publishedon dates meaning it was incredibly difficult to find the duplicates.

    I manually had to copy the publishedon dates from the founding resources to the new resources, as well as make each alias and uri unique, using phpmyadmin - roughly 900 rows worth. What would be the best way to avoid these issues in future?
      • 33968
      • 863 Posts
      Is your php any good? I'm not sure if there's a tool out there that will do it but I would use a script to copy all the resources over and replace all the aliases, preserve publish dates, etc. Wouldn't need to be *too* complex.

      And... hate to say this now but a full backup would have been a great idea before starting. [ed. note: okyanet last edited this post 12 years, 7 months ago.]
        • 20135
        • 188 Posts
        Yeah, we did a full backup, so it's all good. It's just more about how to go about preserving the info.

        My php is ok - was considering writing up a component to do this, it's the sort of thing that I'll come across again, and other may also. I would like to know what I need to do about the duplicate alias issue, and how best to sort that out. Do you have any ideas?
        • This might be an issue with the "duplicate" method:
          http://bugs.modx.com/issues/5471

          or to a related feature request:
          http://bugs.modx.com/issues/5563
            • 20135
            • 188 Posts
            Good call on the feature request. From what we've seen this also needs to address the duplicate alias/uri issue also. I don't know how they might want to do that - maybe there could be a process around identifying if an alias or uri is related to a particular context...

            For the present I'm going to have a shot at creating a Manager page that will sort all of this out. Also, for anyone out there who finds themselves in a situation where multiple contexts are acting as subdomains, I would strongly recommend that within your assets/files folder, you create folders to separate your files according to the subdomains. It's much easier to change a folder name in a uri that it is to uniquely identify all of the duplicate references.