We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    didn't get very far with trying myComponent.

    For a first look, view the MyComponent Resource from the Manager. With the current package set to Example, check the Bootstrap radio button in the UI and click on the Submit button. If you scroll down, you should see a log of all the actions performed by the Bootstrap utility.

    The UI is there, but get just a white screen, when trying to run bootstrap.
    Do I need to configure something before running bootstrap on the Example-project ?

    This question has been answered by Bruno17. See the first response.

      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 3749
      • 24,544 Posts
      You shouldn't have to do anything (assuming that you installed it in Package Manager). It does require you to be logged into the Manager if you're running it inside MODX. The only other thing I can think of is if you modified the example.config.php file, it might not be valid PHP.

      As always, check the error log and check the template used by the MyComponent Resource.
        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
        • 4172
        • 5,888 Posts
        ok, its the php-version here.
        myComponent doesn't work on php-versions before 5.3

        for example because of this line in mcautoload:

                    $lower_basename = function ($string) {
                        return strtolower(basename($string));
                    };


        and this one (lcfirst) in ObjectAdapter::createTransportFile:

         $variableName = lcfirst(substr($type, 3) . 's');
        


        after fixing these both for php < 5.3 bootstrap seems to work. [ed. note: Bruno17 last edited this post 13 years, 7 months ago.]
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 3749
          • 24,544 Posts
          Thanks for checking that out.

          I get the lcfirst() issue, but strtolower() and basename() are both supposed to work in PHP 4 and PHP 5.

          What did you change them to?
            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
            • 4172
            • 5,888 Posts
            $lower_basename = function()


            this syntax was introduced in 5.3

            added this to mcautoload.php:

            if (!function_exists('lower_basename')){
                function lower_basename($string){
                    return strtolower(basename($string));
                }
            } 


            and used it this way:
                           $fnames = array_map('lower_basename', $glob);





            in objectadapter.class.php I added:

            if ( false === function_exists('lcfirst') ):
                function lcfirst( $str )
                { return (string)(strtolower(substr($str,0,1)).substr($str,1));}
            endif; 
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 3749
              • 24,544 Posts
              Thanks Bruno. I'll add those to the next release.

              Did you put both the functions outside the classes?

              Let me know if you run into anything else.
                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
                • 4172
                • 5,888 Posts
                yes, both outside of the classes at top of the files.
                planing to create a UI with MIGX where I can put together the pieces for the config.
                will see how this can go.

                two more questions:
                1. does myComponent support subpackages?
                2. does it make sense to play with the dev-files from github or would you not recommend that.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 3749
                  • 24,544 Posts
                  1. Yes, it puts them in the core/packages directory during the install. You have to search locally for packages, then install them. I don't think that's documented very well yet. You just put the transport.zip files for them in the _build/data/subpackages directory and they go into the package. Installing them all during package installation is on the roadmap, as is moving them to the _build/data/subpakages directory automatically.

                  2. If you mean building MyComponent from the MyComponent files from GitHub, I'd recommend against it. It's a nightmare to work with because it assumes that the build package is somewhere *other* than the MyComponent directory. I have it set up to work with files in the mycomponent2 directory and I have to remember to copy everything over there manually whenever I do an edit. If you just mean grabbing some of the class and snippet files there to update them, that's probably fine, but I'd back up the originals first. There are some bugs fixed in the dev version.

                  If you just install the package, the snippet files should run from the command line or in an editor in addition to running in MODX.
                    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
                    • 4172
                    • 5,888 Posts
                    in mycomponent.php

                    I replaced this:


                                    $tplPath = $modx->getOption('mc.core_path', null, $modx->getOption('core_path') . 'components/mycomponent/') . 'elements/chunks/';
                                    $newTpl = file_get_contents($tplPath . 'example.config.php');


                    with that:

                                    $props = array();
                                    $props['mycomponentCore'] = $modx->getOption('mc.core_path', null, $modx->getOption('core_path') . 'components/mycomponent/');
                                    require_once $props['mycomponentCore'] . 'model/mycomponent/helpers.class.php';                
                                    $helpers = new Helpers($modx,$props);
                                    $helpers->init();
                                    $newTpl = $helpers->getTpl('example.config.php');


                    to be able to have my custom-tpl myexample.config.php as chunk or as file.
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 3749
                      • 24,544 Posts
                      Great idea! Committed.
                        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