We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38878
    • 255 Posts
    I probably poorly posted this in a old thread so sorry for the cross-post.


    First time using really myComponent. Thanks much Bob for developing this. I am trying to figure out how to set some TV Values on the new resources to ID of other newly created resources (i am assuming in the array to set TV values when creating the resource). According to your code above, somewhere in here:

    if (isset($fields['tvValues'])) {
         foreach($fields['tvValues'] as $tvName => $value) {
             $resource->setTVValue($tvName, $value);
         }
    }
    


    Assuming the value is the pagetitle passed from the config script in the tvValues array, that's what I need to resolve. I could do:

    if (isset($fields['tvValues'])) {
         foreach($fields['tvValues'] as $tvName => $value) {
             $get_resource = $modx->getObject('modResource', array('pagetitle' => $value));
             $get_id->get($get_resource=>'id');
             $resource->setTVValue($tvName, $get_id);
         }
    }


    Do I need such a custom resolver? If not how do I reflect this in the build script config to make it happen using the myComponent resolver as is? Or, am I supposed to modify the resource resolver? And if so do I do it after bootstrap and before export?

    Sorry for so many questions. I did read you tut but couldn't find anything more specific on this and thought it might be valuable for others.

    TIA;)

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

    • discuss.answer
      • 3749
      • 24,544 Posts
      I answered in the other thread, but missed the part about using IDs of other newly created resources.

      Just add 'default' in the resolvers section of the project config and run Bootstrap and you'll get a resolver called packageName.resolver.php which will run after all the objects are installed. Your second code section looks right to me.
        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
        • 38878
        • 255 Posts
        Quote from: BobRay at Jul 28, 2015, 06:47 PM
        I answered in the other thread, but missed the part about using IDs of other newly created resources.

        Just add 'default' in the resolvers section of the project config and run Bootstrap and you'll get a resolver called packageName.resolver.php which will run after all the objects are installed. Your second code section looks right to me.

        Thanks Bob. It's interesting that the tvValues array is present on my new resource in the $intersects array after bootstrap but is removed after export. I was getting ready to modify the resolver but noticed the values were missing. Any ideas why this would be?
          • 3749
          • 24,544 Posts
          It could be a cache issue, if you had just run Bootstrap. Check the config file in the project directory (not the MC directory) and see if the Resource section has the TV values.

          I'm not sure that feature has ever been tested all the way to the _build stage, so it may not actually work.

          The TV array in the resource resolver won't really help you anyway, because (if it worked), it would contain the actual settings of the TVs. You want them set based on the objects in the installed package, which would likely have different IDs.
            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
            • 38878
            • 255 Posts
            Quote from: BobRay at Jul 28, 2015, 06:47 PM
            I answered in the other thread, but missed the part about using IDs of other newly created resources.

            Just add 'default' in the resolvers section of the project config and run Bootstrap and you'll get a resolver called packageName.resolver.php which will run after all the objects are installed. Your second code section looks right to me.

            Got this all worked out. Thanks for your help. I am having trouble setting the template for certain resources to "empty". Always seems to revert to default. Tried '0' and 'empty' and ''. All do the same thing.
              • 3749
              • 24,544 Posts
              I'm not sure that's possible. Did you try setting their templates to empty in the Manager and running ExportObjects?

              If that doesn't work, you could always set them to 0 in the default resolver.
                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
                • 38878
                • 255 Posts
                Quote from: BobRay at Aug 01, 2015, 04:25 AM
                I'm not sure that's possible. Did you try setting their templates to empty in the Manager and running ExportObjects?

                If that doesn't work, you could always set them to 0 in the default resolver.

                They were empty in the manager. And I tried to set the template to 0 in the resolver. They ended up with 'default'. I worked around it by creating a custom template that renders like (empty) and associating the resources to that:

                Emtpy.tpl
                <html>
                <head></head>
                    <body>
                        [[*content]]
                    </body>
                </html>
                


                Just in case anyone else runs into this. Thanks for your help.
                  • 3749
                  • 24,544 Posts
                  And I tried to set the template to 0 in the resolver.

                  Which resolver?

                  And what code did you use?
                    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
                    • 38878
                    • 255 Posts
                    Quote from: BobRay at Aug 02, 2015, 05:20 AM
                    And I tried to set the template to 0 in the resolver.

                    Which resolver?

                    And what code did you use?

                    The resource resolver. No worries, the empty-like template works like a charm.
                      • 3749
                      • 24,544 Posts
                      The resource resolver gets overwritten when you run ExportObjects. I meant the generic (default) projectname.resolver.php, which runs after everything is installed.
                        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