We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4971
    • 964 Posts
    Does a plugin works in all documents? or can I tell it to work just in
    the ones I am interested on?

      Website: www.mercologia.com
      MODX Revo Tutorials:  www.modxperience.com

      MODX Professional Partner
      • 27708 MODX Staff
      • 2,502 Posts
      Typically you would check for a condition before running a plugin but you could check for the condition of a document id match then run the actions of your plugin but it will in fact run each time the System Event(s) occurs.

      Pseudo code:

      if (document id == 23){
      do plugin actions;}
      else
      {do nothing ;}

      The plugin will run at every instance of onDocFormSave (if that is the event selected) but will do nothing unless the condition of document id was 23.

      You will obviously need to adjust that to use the real code and api call.

      Cheers,

      Jay
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 4971
        • 964 Posts
        mmm... I thought to do it like that, the problem is that the documents where
        I want my plugin to work are created by the user, so I do not have the ids of the
        future docs...

        is there a way to check for the children of a container document (the parent)?

        What are the parameters for the plugin that can be added in the Configuration tab for?
          Website: www.mercologia.com
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 20413
          • 2,877 Posts
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 4971
            • 964 Posts
            Thanks as always Mrhaw, we should name you the official librarian
            of MODx... wink

            Very helpful link but it does not solve all my challenge as I need
            to pass the parent folder as an argument to the plugin and then
            search for the children and put them on an array to make the decision
            of applying the plugin... I will search in the API to see if there
            is a function childrenOf or something similar...

            thanks again...
              Website: www.mercologia.com
              MODX Revo Tutorials:  www.modxperience.com

              MODX Professional Partner
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: charliez at Oct 14, 2009, 12:01 PM

              Very helpful link but it does not solve all my challenge as I need
              to pass the parent folder as an argument to the plugin and then
              search for the children and put them on an array to make the decision
              of applying the plugin... I will search in the API to see if there
              is a function childrenOf or something similar...
              Is this what you are looking for?
              $modx->getChildIds($modx->documentObject['parent'], 1);

              That will get the id’s of all the immediate children of the current document’s parent. Or change the second parameter to change the depth so you can find children of children, etc.
                • 4971
                • 964 Posts
                Yes Jason, thanks for the help...
                I was reading on all these that seem to do similar stuff...

                getDocumentChildren
                getActiveChildren
                getAllChildren
                getChildIds

                but what I need is getChildIds as you well helped me with...
                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner