We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I assume that snippet lexicon entries should be transferred directly to a new namespace’s default focus in the lexicon as part of a package.

    My questions are:

    1. Should there also be a lexicon file, transferred via a resolver?

    2. If so, where should that file go?

    3. How should it be named?

    And one more question:

    Are lexicon entry variables required to be called $_lang or can they have snippet-specific variable names ($spform_lang). I know there’s no point to this any more with namespaces and foci, but I have a lot of entries that already have those names.
      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
      • 28215
      • 4,149 Posts
      splittingred Reply #2, 18 years ago
      Note: this is only for alpha-4 and later.

      1. Should there also be a lexicon file, transferred via a resolver?
      Nope. It depends on how you’re building the package, either stand-alone via a script, or in the Revo interface.

      If you’re using the GUI, all you have to do is make sure that the lexicon entries are assigned the correct namespace (ie, if you were making spform, you’d create an spform namespace, and then import your foci into there.) Then, when building, make sure the modLexiconFocus and modLexiconEntry auto-includes are selected. It will then autopackage them in.

      If you’re doing it via a script (recommended), then you’d put the lexicons in a directory somewhere (we recommend _build/lexicon/), and run the modPackageBuilder->buildLexicon($path) function. TinyMCE’s looks like this:

      $modx->loadClass('transport.modPackageBuilder','',false, true);
      $builder = new modPackageBuilder($modx);
      $builder->create('tinymce','2.1.0','beta');
      $builder->registerNamespace('tinymce',false,true);
      
      $sources= array (
          'assets' => dirname(dirname(__FILE__)) . '/assets/',
          'root' => dirname(dirname(__FILE__)) . '/',
      );
      
      $c= $modx->newObject('modPlugin');
      $c->set('name', 'TinyMCE');
      $c->set('description', 'TinyMCE 2.1.0-beta plugin for MODx Revolution');
      $c->set('plugincode', file_get_contents($sources['root'] . 'tinymce.plugin.php'));
      $c->set('category', 0);
      
      $attributes= array(
          XPDO_TRANSPORT_UNIQUE_KEY => 'name',
          XPDO_TRANSPORT_PRESERVE_KEYS => true,
          XPDO_TRANSPORT_UPDATE_OBJECT => true,
      );
      $vehicle = $builder->createVehicle($c, $attributes);
      $vehicle->resolve('php',array(
      	'source' => dirname(__FILE__) . '/scripts/add_plugin_events.php',
      ));
      $vehicle->resolve('file',array(
          'source' => $sources['assets'] . 'plugins/tinymce',
          'target' => "return MODX_ASSETS_PATH . 'plugins/';",
      ));
      $builder->putVehicle($vehicle);
      
      // load lexicon strings
      $builder->buildLexicon($sources['root'].'_build/lexicon/');
      
      // load system settings
      $settings = array();
      include_once dirname(__FILE__).'/data/transport.settings.php';
      
      $attributes= array(
          XPDO_TRANSPORT_UNIQUE_KEY => 'key',
          XPDO_TRANSPORT_PRESERVE_KEYS => true,
          XPDO_TRANSPORT_UPDATE_OBJECT => true,
      );
      foreach ($settings as $setting) {
          $vehicle = $builder->createVehicle($setting,$attributes);
          $builder->putVehicle($vehicle);
      }
      
      $builder->pack();
      



      Are lexicon entry variables required to be called $_lang or can they have snippet-specific variable names ($spform_lang). I know there’s no point to this any more with namespaces and foci, but I have a lot of entries that already have those names.
      Currently they are required to be $_lang. We’ll see about changing that later, but you’re right - it’s arbitrary now.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 3749
        • 24,544 Posts
        Quote from: splittingred at Sep 22, 2008, 08:11 AM

        Note: this is only for alpha-4 and later.

        1. Should there also be a lexicon file, transferred via a resolver?
        Nope. It depends on how you’re building the package, either stand-alone via a script, or in the Revo interface.

        If you’re using the GUI, all you have to do is make sure that the lexicon entries are assigned the correct namespace (ie, if you were making spform, you’d create an spform namespace, and then import your foci into there.) Then, when building, make sure the modLexiconFocus and modLexiconEntry auto-includes are selected. It will then autopackage them in.

        My question wasn’t as clear as it might have been. I understand that process and know that’s all that’s needed, but wondered if there was any point to adding a lexicon file containing the entries, say in the snippet directory, for reference purposes and so the user could edit and import the entries. I guess they could do that more easily, though, in the Lexicon Management GUI.

        Thanks for the script version. If only the GUI would generate that script for me. wink

        Why do you recommend the script version over the GUI?

        Re: The alpha-4 note -- What’s missing in alpha-3?

          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