We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16882
    • 7 Posts
    So I’m following Shaun’s tut:
    http://svn.modxcms.com/docs/display/~splittingred/2008/06/26/Writing+a+3rd+Party+Component+in+MODx+Revolution%2C+Pt.+I

    and after successfully running my build file ("build.modxkt.php") -- I assume success ’cause it said "Finished!" I read:

    "That should populate your /doodles/trunk/assets/model/ directory with all the class files and maps"

    No such luck. Don’t know where to start troubleshooting, either. Brand new to modX
    PS: 2.0.0 alpha3
      • 16882
      • 7 Posts
      Opengeek has been very helpful and suggested upgrading to alpha5, which I’ve now done.
      Same issue.
        • 10487 MODX Staff
        • 1,535 Posts
        What does your build script look like?
          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 28215
          • 4,149 Posts
          Also, what does your XML model look like?
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 16882
            • 7 Posts
            Got over that hump, however since I went up to alpha5 the graphical module building stuff doesn’t work for me? Where can I find some current info on doing this manually?
              • 3749
              • 24,544 Posts
              As you’ve discovered, the GUI is not available at this point. I don’t know of a specific tutorial on build scripts yet, although there are some clues in the tutorial link above. If you have access to the components SVN, you can download the sample build script (under templates, I think) or the build script for any of the components (in that component’s build folder) to get an idea of how it’s done.

              Here’s the one I did for EZfaq:

              <?php
              $mtime = microtime();
              $mtime = explode(" ", $mtime);
              $mtime = $mtime[1] + $mtime[0];
              $tstart = $mtime;
              
              $sources= array (
                  'root' => dirname(dirname(__FILE__)) . '/',
                  'assets' => dirname(dirname(__FILE__)) . '/assets/',
              );
              
              /* This example assumes that you are creating one element with one namespace, a lexicon, and one file resolver.
              *  You'll need to modify it if your situation is different. A snippet with no support files (no images, no css, no js includes, etc.) doesn't need a file
              *  resolver so you can comment out that part of the code. If you have no lexicon, you can comment out that part of the code. If you need to create multiple
              *  elements (e.g. a snippet, several chunks, and maybe a plugin) you can do it all in this file, but you'll have to duplicate the code below that creates
              *  and packages the element. You'll also have to reset the variables for each segment. If you put all your support files in or below in a single
              *  directory, you'll only need one file resolver.
              */
              
              $element_namespace = 'ezfaq';    // lexicon namespace for your add-on
              $element_name = 'EZfaq';         // name of your element as it will appear in the Manager
              $element_object_type = 'modSnippet';   // What is it?  modSnippet, modChunk, modPlugin, etc.
              $element_type = 'snippet';   // What is it without the "mod"
              $element_description = 'EZfaq 3.0.5-beta -  Generates a FAQ page for your site.'; // description field in the element's editing page
              $element_source_file = $sources['assets'] . 'ezfaq/snippet.ezfaq.php'; // Where's the file PB will use to create the element
              $element_category = 0;  // the category of the element
              $package_name = $element_name;  // The name of the package as it will appear in Workspaces will be this plus the next two variables
              $package_version = '3.0.5';
              $package_release = 'beta';
              $lexicon_path = $sources['root'] . '_build/lexicon/';  // Where's the lexicon directory
              $resolver_source = $sources['assets'] . 'ezfaq';   // Files in this directory will be packaged
              $resolver_target = "return MODX_ASSETS_PATH . 'snippets/';"; // Those files will go here
              
              /* Note that for file resolvers, the named directory itself is also packaged.
              *  So the two lines above will copy the ezfaq dir and its contents
              *  to the assets/snippets/ directory in the target install.
              */
              
              
              // get rid of time limit
              set_time_limit(0);
              
              // override with your own defines here (see build.config.sample.php)
              require_once dirname(__FILE__).'/build.config.php';
              
              require_once (MODX_CORE_PATH . 'model/modx/modx.class.php');
              $modx= new modX();
              $modx->initialize('mgr');
              //$modx->setDebug(true);
              
              $modx->loadClass('transport.modPackageBuilder','',false, true);
              $builder = new modPackageBuilder($modx);
              $builder->create($package_name,$package_version,$package_release);
              $builder->registerNamespace($element_namespace,false,true);
              
              if (!file_exists($element_source_file)) {
                  echo "<b>Error</b> - Element source file not found: {$element_source_file}<br>";
                  exit();
              }
              
              print "Creating element from source file: {$element_source_file}<br>";
              
              // get the source from the actual element in your database OR
              // manually create the object, grabbing the source from a file
              $c= $modx->newObject($element_object_type);
              $c->set('name', $element_name);
              $c->set('description', $element_description);
              $c->set('category', $element_category);
              $c->set($element_type, file_get_contents($element_source_file));
              
              // create a transport vehicle for the data object
              $attributes= array(
                  XPDO_TRANSPORT_UNIQUE_KEY => 'name',
                  XPDO_TRANSPORT_UPDATE_OBJECT => true,
              );
              $vehicle = $builder->createVehicle($c, $attributes);
              
              echo "<br>Creating Resolver<br>";
              
              if (!is_dir($resolver_source)) {
                  echo "<b>Error</b> - Resolver source directory not found: {$resolver_source}<br>";
                  exit();
              }
              echo "    Source: {$resolver_source}<br>";
              echo "    Target: {$resolver_target}<br><br>";
              
              $vehicle->resolve('file',array(
                  'source' => $resolver_source,
                  'target' => $resolver_target,
              ));
              $builder->putVehicle($vehicle);
              
              if (!is_dir($lexicon_path)) {
                  echo "<b>Error</b> - Lexicon path not found: {$lexicon_path}";
                  exit();
              }
              echo "Creating lexicon from: {$lexicon_path}<br><br>";
              
              // load lexicon strings
              $builder->buildLexicon($lexicon_path);
              
              // zip up the package
              $builder->pack();
              
              $mtime= microtime();
              $mtime= explode(" ", $mtime);
              $mtime= $mtime[1] + $mtime[0];
              $tend= $mtime;
              $totalTime= ($tend - $tstart);
              $totalTime= sprintf("%2.4f s", $totalTime);
              
              echo "Package completed<br>Execution time: {$totalTime}<br>";
              
              exit ();
                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
                • 16882
                • 7 Posts
                okay, that’s a build.transport.php and goes in trunk/_build ?

                what is the purpose of
                build.modxkt.php
                in trunk/_build/schema?

                the GUI Package Builder (were it working) has the purpose of generating build.transport.php?
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: LeFou at Oct 28, 2008, 01:58 PM

                  okay, that’s a build.transport.php and goes in trunk/_build ?

                  what is the purpose of
                  build.modxkt.php
                  in trunk/_build/schema?

                  the GUI Package Builder (were it working) has the purpose of generating build.transport.php?
                  The idea was for the GUI to provide a way of virtually constructing a package in the same way running a build.transport.php would, but we will be exploring better ways to do this after we get over the 2.0 hump.

                  The build in the schema is an xPDO specific script for generating the classes/maps from the database schema.
                    • 3749
                    • 24,544 Posts
                    Quote from: LeFou at Oct 28, 2008, 01:58 PM

                    okay, that’s a build.transport.php and goes in trunk/_build ?
                    Right. And you also need a build.config.php file there, edited to match your setup (see build.config.sample.php).

                    what is the purpose of
                    build.modxkt.php
                    in trunk/_build/schema?
                    I’m not sure. I’ve never needed to mess with it (in fact, my add-on _build directories don’t have that file). I would guess it’s used if your add-on has it’s own data table in the DB.


                    The GUI Package Builder (were it working) has the purpose of generating build.transport.php?
                    No, both the GUI Package Builder and build.transport.php have the purpose of generating your_add-on.transport.zip in the core/packages directory. It’s the actual package -- ready for installation. To install, the user puts it (or downloads it, or gets it from the WTF) into their core/packages directory and installs it though the MODx Manager.
                      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