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

    my transport builder script produces a wrong Assets path entry in namespaces. But I can't find what's wrong.
    I'm using the following code:

    ...
    $modx->loadClass('transport.modPackageBuilder', '', false, true);
    $builder = new modPackageBuilder($modx);
    $builder->directory = $sources['packages'];
    $builder->createPackage(PKG_NAME_LOWER, PKG_VERSION, PKG_RELEASE);
    $builder->registerNamespace(PKG_NAME_LOWER, false, true, '{core_path}components/'.PKG_NAME_LOWER.'/');
    ...
    


    This generates a namespace entry with the following values:

    Name:  mypackage
    Core path:  {core_path}components/mypackage/
    Assets path:  /var/www/modx/wwwRoot/development/mypackage/assets/components/mypackage/
    


    But the Assets path value should be:

    Assets path:  {assets_path}components/mypackage/
    


    What am I doing wrong?

    Greetings,
    Martin

    This question has been answered by multiple community members. See the first response.

      Freelancer @bitego http://www.bitego.com
      ---
      GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
      More infos here: http://www.bitego.com/extras/goodnews/
    • discuss.answer
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Replace
      $builder->registerNamespace(PKG_NAME_LOWER, false, true, '{core_path}components/'.PKG_NAME_LOWER.'/');

      with
      $builder->registerNamespace(PKG_NAME_LOWER, false, true, '{core_path}components/'.PKG_NAME_LOWER.'/', '{assets_path}components/'.PKG_NAME_LOWER.'/');
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 10378
        • 375 Posts
        Hi Mark,

        in the meantime I had a look at the registerNamespace method of modpackagebulder.class.php and saw there is an undocumented parameter $assetsPath. What I don't understand is, where does the full absolute path come from which lands in my namespaces table?

            public function registerNamespace($ns = 'core', $autoincludes = true, $packageNamespace = true, $path = '',$assetsPath = '') {
                if (!($ns instanceof modNamespace)) {
                    $namespace = $this->modx->getObject('modNamespace', $ns);
                    if (!$namespace) {
                        $namespace = $this->modx->newObject('modNamespace');
                        $namespace->set('name', $ns);
                        $namespace->set('path',$path);
                        $namespace->set('assets_path',$assetsPath);
                    }
                    if (!empty($path)) {
                        $namespace->set('path',$path);
                    }
                    if (!empty($assetsPath)) {
                        $namespace->set('assets_path',$assetsPath);
                    }
                ...
        


        The code above say the assets_path field should be empty when using this to create a namespace:

        $builder->registerNamespace(PKG_NAME_LOWER, false, true, '{core_path}components/'.PKG_NAME_LOWER.'/');
        
        [ed. note: gadgetto last edited this post 12 years, 11 months ago.]
          Freelancer @bitego http://www.bitego.com
          ---
          GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
          More infos here: http://www.bitego.com/extras/goodnews/
          • 10378
          • 375 Posts
          By the way - is it necessary to set the assets_path in namespaces?
            Freelancer @bitego http://www.bitego.com
            ---
            GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
            More infos here: http://www.bitego.com/extras/goodnews/
            • 3749
            • 24,544 Posts
            No, unless you're using it yourself. Many add-on packages leave it blank.
              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
            • discuss.answer
              • 10378
              • 375 Posts
              Quote from: BobRay at Nov 11, 2013, 02:10 PM
              No, unless you're using it yourself. Many add-on packages leave it blank.

              OK - thanks!

              Any clue why the assets_path is set to a full absolute path within my transport builder even though I don't set this parameter with the registerNamespace call?
                Freelancer @bitego http://www.bitego.com
                ---
                GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
                More infos here: http://www.bitego.com/extras/goodnews/
                • 3749
                • 24,544 Posts
                Looking at the code (including createVehicle() and the constructor) , I don't see any way that could happen. wink

                As you noted, the default value of that argument is '' and as far as I can see, there's no code that alters it. It's a genuine mystery.
                  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
                  • 18373 ☆ A M B ☆
                  • 3,141 Posts
                  If the namespace exists in your dev site (which it most likely does), it gets that namespace object from the system. It only overrides it with what you specify in the function parameters. So your dev site probably has that assets path set, or it is automatically calculated in the modNamespace class.

                  Indeed the assets_path isn't typically used in MODX currently, though the idea I think is for namespaces to become more of a container for extras. This already happens for the path (lexicons, controllers etc) but not yet for assets.
                    Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                    Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.