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

    I'm trying to create my own TransportPackage. I added an install.script.php file to create a document if user checks the box during install.

    According to Bob Ray book, I have to add those lines to create my package :

    $vehicle->resolve('php', array(
    		'type' => 'php',
    		'source' => 'install.script.php',
    		));


    But it doesn't work, script is stopped executing this function and package is not created. After a look, I found that the resolve() is not in modpackagebuilder.class.php as the putVehicle or createVehicle functions are but in modtrabsportvehicle.class.php

    I work with Revolution 2.2.1-dev

    Thanks !
      • 3749
      • 24,544 Posts
      It might work if you use the full path to the install script. Please try that first and let me know so I'll know if the book needs correcting (BTW, what page is that on?).

      The 'type' member is no longer necessary, so if that doesn't work, try this:


      $vehicle->resolve('php',array(
          'source' => 'path/to/install/script'',
      ));
      



      Be sure you've created the resolver first.


      FYI, if your package is at all complex, you might want to look at the GetMyComponent package (http://bobsguides.com/mycomponent-tutorial.html)which has a big example package install that you can modify to do almost anything you want and a detailed tutorial. I use it all the time.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 38925
        • 38 Posts
        Sorry for the late, my studies take me so much time sad

        So I tried this :

        echo `ls _build/`; 
        	
        	$vehicle->resolve('php', array(
        		'source' => '_build/install.script.php',
        		));
        	echo '
         resolve done';


        The page send back this :

        Creating package
        install.script.php user.input.php


        resolve still doesn't work sad

        In the book it's page 619.

        Thanks !

        EDIT : It seems to work well. I had an error in my variable name.
        EDIT2 : The resolve method works well, but I have some issues in my install.script.php. I'll try to resolve this and go back here in case of dead end.



        [ed. note: tzoreol last edited this post 14 years, 6 months ago.]
          • 38925
          • 38 Posts
          I still have issues with install.script.php. As describe in the book, I want to create a document who calls the snippet. But the document isn't created.

          Here is my file :

          <?php
          	
          	//Install package with selected configuration
          	
          	$modx =& $object->xpdo;
          	$default_template = $modx->config['default_template'];
          	
          	$success = false;
          	switch( $options[xPDOTransport::PACKAGE_ACTION])
          	{
          		case xPDOTransport::ACTION_INSTALL:
          			if( isset($options['create_document']) && $options['create_document'] == 'Yes')
          			{
          				$modx->log(xPDO::LOG_LEVEL_INFO, "Creating AddUsers document");
          				$r = $modx->newObject('modResource');
          				$r->set('class_key', 'modDocument');
          				$r->set('context_key', 'web');
          				$r->set('type', 'document');
          				$r->set('contentType', 'text/html');
          				$r->set('pagetitle', 'AddUsers');
          				$r->set('longtitle', 'AddUsers Page');
          				$r->set('description', 'Executes and shows output of ImportUsers Snippet');
          				$r->set('alias', 'addusers');
          				$r->set('published', '1');
          				$r->set('parent', '0');
          				$r->setContent('[[ImportUsers]]');
          				$r->set('richtext', '0');
          				$r->set('menuindex', '99');
          				$r->set('searchable', '1');
          				$r->set('cacheable', '1');
          				$r->set('hidemenu', '1');
          				$r->set('template', $default_template);
          				$r->save();
          				$success = true;
          			}
          			break;
          		case xPDOTransport::ACTION_UPGRADE:
          			$success = true;
          			break;
          		case xPDOTransport::ACTION_UNINSTALL:
          			if( false === $modx->removeObject('modResource', array('name' => 'AddUsers')))
          			{
          				$modx->log(xPDO::LOG_LEVEL_INFO, "<br/><strong>NOTE: You may to remove the AddUsers Page manually</strong><br/>");
          			}
          			$success = true;
          			break;
          	}
          	
          	return $success;


          Even without the condition in first case AddUsers isn't created.
            • 22303 MODX Staff
            • 10,725 Posts
            First, when you create a modResource, create it using the subclass instead of manually set()'ing the class_key, e.g.
            $modx->newObject('modDocument');
              • 38925
              • 38 Posts
              I've made the change but it's still not working sad

              EDIT : Problem solved. I was adding adding my install file in the vehicle after adding vehicle in the builder. [ed. note: tzoreol last edited this post 14 years, 6 months ago.]