We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34018 ☆ A M B ☆
    • 100 Posts
    What's up guys!

    I really wanted to know how you guys do when dealing with the extras/plugin development using Git.

    I mean, what do you do to separate the MODX core from the plugin you are developing in, and if you guys have examples of .gitignore files or something like that and could share with us, it would be very apreciated.

    Thanks in advance MODXers!
      ----
      Daniel Melo
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The Doodles tutorial has pretty good setup instructions for that. http://rtfm.modx.com/revolution/2.x/case-studies-and-tutorials/developing-an-extra-in-modx-revolution
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 34018 ☆ A M B ☆
        • 100 Posts
        Oh, thank you Sottwell!

        I'll read and follow the tutorial instructions.

        Is there anyway to develop the extra without separating it from the core, like using another .gitignore file, or that's useless?
          ----
          Daniel Melo
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Check out BobRay's MyComponent. It works very well. http://bobsguides.com/mycomponent-tutorial.html
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 3749
            • 24,544 Posts
            MyComponent puts all extras in assets/mycomponents/componentname.

            There's a trick (I think invented by splittingred) that lets you run the extra from that location in your dev. environment, but runs it from core/components when it's installed. I think it's documented in the Doodle tutorial.

            Basically, you System Setting for the component's core path, assets path, and assets url (you don't always need all three). Then, all includes in your code use something like this:

            include $modx->getOption('nf.core_path', null, $modx->getOption('core_path') . 
                'components/mycomponent/') . 'model/mycomponent/notify.class.php';


            This setting is for the Notify extra and nf.core_path is set to:

            {assets_path}mycomponents/notify/core/components/notify/


            If the setting exists, it includes the file at:

            assets/mycomponents/notify/assets/components/notify/model/notify.class.php


            if the setting doesn't exist (as it wouldn't when Notify is installed by an end user), it included the file at:

            core/components/notify/model/notify.class.php


            getOption() works like this:

            $modx->getOption('setting_to_look_for', $where to look, 'default to use if not found');


            With null as the second argument, it will check the System Settings.

            In system settings, {core_path} will evaluate to the MODX core path.

            One gotcha with this is if you are creating a CMP. In that case you need to manually modify the core path of the namespace too and make sure that modification doesn't go into the final distribution. If you forget, your CMP is DOA for the end user.

            A second gotcha is that the lexicon strings won't be read from your dev. location ($modx->lexicon->load() doesn't accept a path -- though it really should -- and always loads from the namespace path). You have to manually copy the lexicon files to core/components/componentname/lexicon.



            A word of warning: Before releasing an extra, always test it in a relatively fresh install of MODX where none of the dev. System Settings are set to make sure it works. wink
              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
              • 34018 ☆ A M B ☆
              • 100 Posts
              Thank you very much Bob, I think I'm well oriented now! Will use this method for sure on my extras development!

              Best Regards!
                ----
                Daniel Melo