We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38783
    • 571 Posts
    This is an observation that might help others, not a question.
    (But it is not a 'Discussion', hence posting it under 'Questions' - apologies if this is Bad Practice - feel free to move or re-categorise if necessary).


    This is now re classified as a question!

    I wanted to use some Template Variables that I had set up in an old site in a new site.

    I transferred the contents of the following tables from one site to another using phpMyAdmin:
    site_tmplvars
    site_tmplvar_contentvalues
    site_tmplvar_templates

    Unfortunately not all my template variables appeared in managers Elements tree.

    It turned out that I had applied Categories to the TVs in the old site. The new site had the same Categories in it, but they had been created manually and had different IDs in the database tables. Changing the IDs in the 'categories' table to match those in the old site fixed the problem.

    If I discover that changing the IDs in the 'categories' table to match those in the old site causes some awful, unforseen problem with the new site I will amend this post.


    Should I have done this?

    This question has been answered by BobRay. See the first response.

    [ed. note: andytough last edited this post 13 years, 8 months ago.]
      If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

      email: [email protected] | website: https://andytough.com
    • discuss.answer
      • 3749
      • 24,544 Posts
      The second two of those contain pairs of IDs. The tmplvar_contentvalues have the id of a resource and the id of a template variable. If the site already had resources and TVs, the odds of them being correct are slim even though some may appear to be correct if they show the default value of the TV or are correct by accident.

      The same goes for the tmplvar_templates which contain the ID of a Template and the ID of a TV. The only really safe way to do what you're trying to do is either to just transfer the site_templvars table and set the resource values and templates they connect to manually or to use MyComponent to create a transport package for the TVs and Templates, it will use the names to make the connections, but it's fairly complicated to set up if you're not used to it.

      Changing the category IDs manually is also dangerous unless you're careful not to have duplicate IDs. It would have been safer to change the category field of the TVs to match the IDs of the existing categories.

        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
        • 38783
        • 571 Posts
        Hi Bob, thanks for the response.

        Fortunately the resources a had been imported from the old site, so they had the same ID's.

        There were no existing TVs in the new site, so the IDs of the imported ones were identical and didn't clash with any existing ones.

        I'd changed the ID of the template used in the new site, to be the same as the ID of the template in the old site.

        The categories I recreated with identical IDs.

        So, fingers crossed, I should be OK. I'll bear in mind the advice before considering doing anything like this again.

        I think I am at that stage of learning with MODX where I know just enough to be dangerous. It is just as well you are there to set me straight!

        Thanks

        Andy
          If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

          email: [email protected] | website: https://andytough.com
          • 3749
          • 24,544 Posts
          It sounds like you have everything under control. I just didn't want others to think you could do that casually and end up trashing their sites. wink

            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
            • 38783
            • 571 Posts
            Thanks Bob smiley
              If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

              email: [email protected] | website: https://andytough.com