We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18878
    • 210 Posts
    Hi,

    My site has lots of template variables. When I add a new Template I have to give all those TVs access to the new template one by one manually.

    Does anyone know give a Template Access to several Template Variables at once?

    Thanks.
      • 11975
      • 2,542 Posts
      Hi,

      Unfortunately this feature is not included in tvEditor :-(

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 18878
        • 210 Posts
        Quote from: heliotrope at Nov 19, 2007, 10:21 AM

        Hi,

        Unfortunately this feature is not included in tvEditor :-(

        :-)

        ohh.. sad
          • 7231
          • 4,205 Posts
          I am suffering with the same issue, it would be cool to have the TV assignment be duplicated along with the template. I am learning that it is important to be well organized ahead of time with things like templates and document groups ahead of time because some of these will be a hassle to add afterwards.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 18878
            • 210 Posts
            Quote from: ganeshXL at Nov 19, 2007, 10:44 AM

            Check out these 3 tables in phpMyAdmin:

            The table modx_site_tmplvars shows the id numbers of each template variable.
            Table modx_site_templates shows the id numbers of your templates.

            Table modx_site_tmplvar_templates sets the relations between templates and template variables, i.e. which template has access to which TV.

            (replace "modx_" with whatever prefix you’re using)

            It should be easy to manually write a little query to update several template/TV relationships at once. If you’re paranoid, make a backup of these 3 tables beforehand, so you can revert to the old data if anything goes wrong.


            Hey, Thanks a lot for the tip!
              • 18878
              • 210 Posts
              Ok, if some newbies are interested, here goes the little script I wrote that will do the job.

              Follow the steps below:

              1) Obtain the id of the Template you want to work with. Execute:

              select * from modx_site_templates where templatename='TheTemplateNameInTheModxManager';


              2) Create a backup of the modx_site_tmplvar_templates table (so you can revert if anything goes wrong):

              create table modx_site_tmplvar_templates_bk as
              select * from modx_site_tmplvar_templates;
              

              3) Finally, insert the new values on table modx_site_tmplvar_templates. Suppose the id you obtained in step 1) is 9. The following command will give template 9 access to ALL existing Template Variables (You should modify it if you want to restrict it to only some TVs).

              insert into modx_site_tmplvar_templates 
              select id, 9, 0 from modx_site_tmplvars;
              

              4) Check all TVs in Content Manager and verify that they all have access to the Template 9.

              Hope it helps. wink

              Mc