We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    What is the best way to create a simple template package? Just to have templates, chunks, TVs, resources, and the templates' support files.

    I've had some success using MyComponent, but that likes to put all files into assets/components/templatename, and I want the files to be installed into assets/templates/templatename, assets/images and assets/js.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 4172
      • 5,888 Posts
      Not sure about this and didn't try it,
      but I think, you can have additional sources and targets in the build-script-template with MyComponent

      by adding modified versions of this part:
          /* This section transfers every file in the local
             mycomponents/mycomponent/assets directory to the
             target site's assets/mycomponent directory on install.
           */
      
          if ($hasAssets && $i == 1) {
              $helper->sendLog(MODX::LOG_LEVEL_INFO,
              $modx->lexicon('mc_packaged_assets_files'));
              $vehicle->resolve('file', array(
                                             'source' => $sources['source_assets'],
                                             'target' => "return MODX_ASSETS_PATH . 'components/';",
                                        ));
          }
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        What it really needs to be able to do is to allow arbitrary file sources, then have the target be equal to the source_assets. For example, specify as file source to be "assets/images, assets/js, assets/templates/mytemplate", and the target will be the same, creating the directories if necessary.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 3749
          • 24,544 Posts
          MC already allows specifying file names, it should be possible for me to add a little code to let the user give a full path to the file.

            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
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I've been looking at the code, but so far all I've accomplished is a headache.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I am still horribly confused with MyComponent. Where do I have to put my files (.css, .js, images) in the MyComponents structure to get them packaged so that they will be installed in assets/components/whatever/ ?

              I will have three subdirectories:

              whatever/css
              whatever/js
              whatever/images

              My package is "whatever".
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 3749
                • 24,544 Posts
                If you specified the assets stuff in the config file, the directories should already be there (and possibly skeleton files).

                They would be at:

                assets/mycomponents/whatever/assets/components/whatever/css/
                assets/mycomponents/whatever/assets/components/whatever/js/
                assets/mycomponents/whatever/assets/components/whatever/images/
                

                On installation, they will automatically go to
                assets/components/whatever/css/
                assets/components/whatever/js/
                assets/components/whatever/images/
                

                The more generic answer is that everything in this directory:
                assets/mycomponents/whatever/assets/

                will get transferred on install to
                assets/

                and everything in
                assets/mycomponents/whatever/core/

                will get transferred on install to
                core/




                  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
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Ah! Finally I think I've got it! Thank you!

                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 3749
                    • 24,544 Posts
                    I used to get confused about it all the time. Eventually, it kind of makes sense. 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